From 51d5397e92c36ff3c8084383e2ae91574fcc2c07 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 7 Jan 2024 21:48:03 -0500 Subject: [PATCH] LibGfx: Give ImageDecoder an API for getting raw CMYK data frame() still returns a regular RGB Bitmap, but it's possible to also get at raw CMYK data instead if desired, for image formats that can store that. --- Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.h b/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.h index aadc4ef74e..92626d37c4 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.h +++ b/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -30,6 +31,7 @@ struct VectorImageFrameDescriptor { enum class NaturalFrameFormat { RGB, + CMYK, Vector, }; @@ -59,6 +61,7 @@ public: virtual ErrorOr> icc_data() { return OptionalNone {}; } virtual NaturalFrameFormat natural_frame_format() const { return NaturalFrameFormat::RGB; } + virtual ErrorOr> cmyk_frame() { VERIFY_NOT_REACHED(); } virtual ErrorOr vector_frame(size_t) { VERIFY_NOT_REACHED(); } protected: @@ -82,6 +85,9 @@ public: NaturalFrameFormat natural_frame_format() { return m_plugin->natural_frame_format(); } + // Call only if natural_frame_format() == NaturalFrameFormat::CMYK. + ErrorOr> cmyk_frame(size_t) { return m_plugin->cmyk_frame(); } + // Call only if natural_frame_format() == NaturalFrameFormat::Vector. ErrorOr vector_frame(size_t index) { return m_plugin->vector_frame(index); }