1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:47:35 +00:00

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.
This commit is contained in:
Nico Weber 2024-01-07 21:48:03 -05:00 committed by Andreas Kling
parent bc6eebb1d7
commit 51d5397e92

View file

@ -11,6 +11,7 @@
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/CMYKBitmap.h>
#include <LibGfx/Size.h>
#include <LibGfx/VectorGraphic.h>
@ -30,6 +31,7 @@ struct VectorImageFrameDescriptor {
enum class NaturalFrameFormat {
RGB,
CMYK,
Vector,
};
@ -59,6 +61,7 @@ public:
virtual ErrorOr<Optional<ReadonlyBytes>> icc_data() { return OptionalNone {}; }
virtual NaturalFrameFormat natural_frame_format() const { return NaturalFrameFormat::RGB; }
virtual ErrorOr<NonnullRefPtr<CMYKBitmap>> cmyk_frame() { VERIFY_NOT_REACHED(); }
virtual ErrorOr<VectorImageFrameDescriptor> 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<NonnullRefPtr<CMYKBitmap>> cmyk_frame(size_t) { return m_plugin->cmyk_frame(); }
// Call only if natural_frame_format() == NaturalFrameFormat::Vector.
ErrorOr<VectorImageFrameDescriptor> vector_frame(size_t index) { return m_plugin->vector_frame(index); }