CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
working_image_data.h
Go to the documentation of this file.
1
36#pragma once
37
38#include "common/image_region.h"
41
42#include <memory>
43#include <expected>
44#include <cstddef>
45
46namespace CaptureMoment::Core {
47
48namespace ImageProcessing {
49
65
66public:
67
75 explicit WorkingImageData(std::unique_ptr<Common::ImageRegion> source);
76
77 virtual ~WorkingImageData() = default;
78
79 // Non-copyable by default (expensive), but movable
82 WorkingImageData(WorkingImageData&&) noexcept = default;
83 WorkingImageData& operator=(WorkingImageData&&) noexcept = default;
84
88 [[nodiscard]] std::expected<void, ErrorHandling::CoreError>
89 initializeData(Common::ImageRegion&& source_image);
90
95 [[nodiscard]] std::span<const float> getOriginalDataSpan() const noexcept {
96 return std::span<const float>(m_original_data);
97 }
98
103 [[nodiscard]] std::span<const float> getWorkingDataSpan() const noexcept {
104 return std::span<const float>(m_data);
105 }
106
111 [[nodiscard]] std::span<float> getWorkingDataSpan() noexcept {
112 return std::span<float>(m_data);
113
114 }
115
120 [[nodiscard]] Common::ImageDim getWidth() const noexcept { return m_width; }
121
126 [[nodiscard]] Common::ImageDim getHeight() const noexcept { return m_height; }
127
132 [[nodiscard]] Common::ImageChan getChannels() const noexcept { return m_channels; }
133
138 [[nodiscard]] bool isValid() const noexcept { return m_valid; }
139
147 void restoreOriginalData();
148
149private:
161 std::vector<float> m_data;
162
168 std::vector<float> m_original_data;
169
179 Common::ImageSize m_data_size{0};
180
188 Common::ImageDim m_width{0};
189
196 Common::ImageDim m_height{0};
197
204 Common::ImageChan m_channels{0};
205
217 bool m_valid{false};
218
219};
220
221} // namespace ImageProcessing
222
223} // namespace CaptureMoment::Core
Base class providing raw buffer storage and metadata for working images.
WorkingImageData(const WorkingImageData &)=delete
std::expected< void, ErrorHandling::CoreError > initializeData(Common::ImageRegion &&source_image)
Re-initializes the internal buffer with a new ImageRegion.
WorkingImageData & operator=(const WorkingImageData &)=delete
WorkingImageData(std::unique_ptr< Common::ImageRegion > source)
Initializes the working image data from an ImageRegion.
void restoreOriginalData()
Restores the original image data.
std::span< const float > getOriginalDataSpan() const noexcept
Returns a non-owning, CONST span over the ORIGINAL pixel data.
std::span< float > getWorkingDataSpan() noexcept
Returns a non-owning, MUTABLE span over the working pixel data.
Common::ImageChan getChannels() const noexcept
Return the number of color channels in the image.
WorkingImageData(WorkingImageData &&) noexcept=default
bool isValid() const noexcept
Checks if the data buffer is valid and allocated.
Common::ImageDim getHeight() const noexcept
Return the height of the image in pixels.
Common::ImageDim getWidth() const noexcept
Return the width of the image in pixels.
std::span< const float > getWorkingDataSpan() const noexcept
Returns a non-owning, CONST span over the working pixel data.
Central error handling system for CaptureMoment Core library.
Defines the ImageRegion structure for representing pixel buffers in the CaptureMoment Core library.
Common type definitions for all image types in CaptureMoment.
std::size_t ImageSize
Type for data size (element count).
Definition image_types.h:38
std::uint8_t ImageChan
Type for channel count.
Definition image_types.h:26
std::size_t ImageDim
Type for image dimensions (width, height).
Definition image_types.h:20
@ ImageProcessing
Errors related to Image Processing, GPU, or Memory.
Manages the lifecycle of a single IWorkingImage instance.
Contains the error handling infrastructure for the Core library.
CaptureMoment — footer