13#include <spdlog/spdlog.h>
19 : m_state_manager(std::make_unique<Managers::StateImageManager>())
21 spdlog::debug(
"PhotoEngine: Constructed with StateImageManager.");
26 if (!m_state_manager) {
27 spdlog::error(
"PhotoEngine::loadImage: StateImageManager is null.");
34 if (!m_state_manager->loadImage(path)) {
35 spdlog::error(
"PhotoEngine::loadImage: Failed to load image '{}'.", path);
40 auto process_result = m_state_manager->resetToOriginal();
42 if (!process_result) {
43 return std::unexpected(process_result.error());
46 spdlog::info(
"PhotoEngine: Loaded image '{}' successfully.", path);
52 if (!m_state_manager) {
55 return m_state_manager->commitWorkingImageToSource();
60 if (!m_state_manager)
return;
62 spdlog::debug(
"PhotoEngine: Resetting working image.");
63 (void) m_state_manager->resetToOriginal();
68 return m_state_manager->getSourceWidth();
73 return m_state_manager->getSourceHeight();
78 return m_state_manager->getSourceChannels();
83 if (!m_state_manager) {
84 spdlog::error(
"PhotoEngine::applyOperations: StateImageManager is null.");
85 return std::async(std::launch::deferred, []() {
return false; });
88 spdlog::info(
"PhotoEngine::applyOperations: Received {} operations.", ops.size());
89 return m_state_manager->applyOperations(std::move(ops));
94 if (!m_state_manager) {
95 spdlog::error(
"[PhotoEngine::getWorkingImageAsRegion]: StateManager is null.");
99 auto result = m_state_manager->getWorkingImageAsRegion();
102 spdlog::error(
"[PhotoEngine::getWorkingImageAsRegion]: Failed to get working image.");
103 return std::unexpected(result.error());
112 if (!m_state_manager) {
115 return m_state_manager->getDownsampledDisplayImage(
width,
height);
Common::ImageDim width() const noexcept
Gets the width of the loaded image.
std::expected< void, ErrorHandling::CoreError > loadImage(std::string_view path)
Loads an image file and initializes the processing pipeline.
Common::ImageDim height() const noexcept
Gets the height of the loaded image.
void resetWorkingImage()
Resets the working image to the original state.
Common::ImageChan channels() const noexcept
Gets the number of color channels.
std::expected< std::unique_ptr< Common::ImageRegion >, ErrorHandling::CoreError > getDownsampledDisplayImage(Common::ImageDim width, Common::ImageDim height)
std::expected< void, ErrorHandling::CoreError > commitWorkingImageToSource()
Commits the processed working image back to the source manager.
std::expected< std::unique_ptr< Common::ImageRegion >, ErrorHandling::CoreError > getWorkingImageAsRegion() const
Gets the working image as a CPU-based copy.
PhotoEngine()
Constructs a PhotoEngine instance.
std::future< bool > applyOperations(std::vector< Operations::OperationDescriptor > &&ops)
Applies a cumulative list of operations.
std::uint8_t ImageChan
Type for channel count.
std::size_t ImageDim
Type for image dimensions (width, height).
CoreError
Enumeration of all error codes for CaptureMoment Core.
@ IOError
Generic File I/O error.
@ Unexpected
An unexpected error occurred.
Declaration of PhotoEngine class.
Declaration of StateImageManager class.