CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
CaptureMoment::Core::Utils Namespace Reference

Typedefs

using ColorSpaceInfo = std::pair<bool, std::string>
 Result of a color space analysis.
 

Functions

std::string getColorSpace (const OIIO::ImageBuf &buf) noexcept
 Extracts the color space name from an OIIO image buffer metadata.
 
bool isLinearToken (std::string_view colorspace) noexcept
 Checks whether an OIIO-detected color space token represents linear data.
 
ColorSpaceInfo analyzeColorSpace (const OIIO::ImageSpec &spec) noexcept
 Analyzes whether an image's pixel data is stored in a linear color space.
 
std::expected< void, ErrorHandling::CoreError > transformToColorSpace (OIIO::ImageBuf &image, std::string_view target_cs)
 Converts an image buffer to a target color space (in-place).
 
std::unique_ptr< Common::ImageRegion > convert_RGBA_F32_to_RGBA_U8 (const Common::ImageRegion &input)
 Converts an RGBA_F32 ImageRegion to a new RGBA_U8 ImageRegion.
 

Typedef Documentation

◆ ColorSpaceInfo

using CaptureMoment::Core::Utils::ColorSpaceInfo = std::pair<bool, std::string>

Result of a color space analysis.

First element: true if the image data uses a linear transfer function. Second element: the detected color space name (CIF token). Empty if OIIO could not determine it.

Definition at line 34 of file color_space_utils.h.

Function Documentation

◆ getColorSpace()

std::string CaptureMoment::Core::Utils::getColorSpace ( const OIIO::ImageBuf & buf)
nodiscardnoexcept

Extracts the color space name from an OIIO image buffer metadata.

Returns
The detected color space name, or empty string if not found.

Definition at line 15 of file color_space_utils.cpp.

Referenced by transformToColorSpace().

◆ isLinearToken()

bool CaptureMoment::Core::Utils::isLinearToken ( std::string_view colorspace)
nodiscardnoexcept

Checks whether an OIIO-detected color space token represents linear data.

Matches against known CIF (Color Interop Forum) linear tokens:

  • "lin_rec709_scene" (synonyms: "lin_rec709", "lin_srgb", "Linear")
  • "lin_ap1_scene" (synonym: "ACEScg")
  • "lin_ap0_scene"
  • "scene_linear" (OCIO role)
Parameters
colorspaceThe color space name from OIIO metadata.
Returns
true if the token represents a linear transfer function.

Definition at line 21 of file color_space_utils.cpp.

Referenced by analyzeColorSpace().

◆ analyzeColorSpace()

ColorSpaceInfo CaptureMoment::Core::Utils::analyzeColorSpace ( const OIIO::ImageSpec & spec)
nodiscardnoexcept

Analyzes whether an image's pixel data is stored in a linear color space.

Reads the "oiio:ColorSpace" attribute that OIIO sets automatically during file reading. Does not read the file — uses OIIO's metadata only.

Parameters
specThe OIIO ImageSpec to inspect.
Returns
ColorSpaceInfo with linear status and detected color space name.
Note
If OIIO did not set "oiio:ColorSpace" (e.g., BMP, ICO without metadata), returns {false, ""}. The caller should apply a fallback strategy.

Definition at line 46 of file color_space_utils.cpp.

References isLinearToken().

◆ transformToColorSpace()

std::expected< void, ErrorHandling::CoreError > CaptureMoment::Core::Utils::transformToColorSpace ( OIIO::ImageBuf & image,
std::string_view target_cs )
nodiscard

Converts an image buffer to a target color space (in-place).

Reads the source color space from the buffer's OIIO metadata ("oiio:ColorSpace") and converts to the specified target.

Parameters
imageThe image buffer to convert (modified in-place).
target_csThe target color space CIF token (e.g., "lin_rec709_scene").
Returns
Success or CoreError on failure.

Definition at line 58 of file color_space_utils.cpp.

References CaptureMoment::Core::ErrorHandling::DecodingError, getColorSpace(), and CaptureMoment::Core::ErrorHandling::InvalidWorkingImage.

◆ convert_RGBA_F32_to_RGBA_U8()

CaptureMoment — footer