LibGfx: Allow ImageDecoders to expose their color space through CICP

This introduces a new API in ImageDecoderPlugins that allow an image
decoder to return a CICP struct. Also, we use this API in
ImageDecoder::color_space() to create a color space corresponding to
these CICP.
This commit is contained in:
Lucas CHOLLET 2025-02-08 00:07:28 -05:00 committed by Tim Flynn
commit cffc8678d8
Notes: github-actions[bot] 2025-02-12 17:26:15 +00:00
4 changed files with 36 additions and 0 deletions

View file

@ -49,6 +49,10 @@ static ErrorOr<OwnPtr<ImageDecoderPlugin>> probe_and_sniff_for_appropriate_plugi
ErrorOr<ColorSpace> ImageDecoder::color_space()
{
auto maybe_cicp = TRY(m_plugin->cicp());
if (maybe_cicp.has_value())
return ColorSpace::from_cicp(*maybe_cicp);
auto maybe_icc_data = TRY(icc_data());
if (!maybe_icc_data.has_value())
return ColorSpace {};

View file

@ -16,6 +16,7 @@
#include <LibGfx/ColorSpace.h>
#include <LibGfx/Size.h>
#include <LibGfx/VectorGraphic.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
namespace Gfx {
@ -86,6 +87,7 @@ public:
virtual Optional<Metadata const&> metadata() { return OptionalNone {}; }
virtual ErrorOr<Optional<Media::CodingIndependentCodePoints>> cicp() { return OptionalNone {}; }
virtual ErrorOr<Optional<ReadonlyBytes>> icc_data() { return OptionalNone {}; }
virtual NaturalFrameFormat natural_frame_format() const { return NaturalFrameFormat::RGB; }