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

LibPDF+LibGfx: Don't invert CMYK channels in JPEG data in PDFs

This is a hack: Ideally we'd have a CMYK Bitmap pixel format,
and we'd convert to rgb at blit time. Then we could also apply color
profiles (which for CMYK images are CMYK-based).

Also, the colors for our CMYK->RGB conversion are off for PDFs,
and we have distinct codepaths for this in Gfx::Color (for paths)
and JPEGs. So when we fix that, we'll have to fix it in two places.

But this doesn't require a lot of code and it's a huge visual
progression, so let's go with it for now.
This commit is contained in:
Nico Weber 2023-11-15 12:58:06 -05:00 committed by Sam Atkins
parent bd7ae7f91e
commit bfe27228a3
3 changed files with 26 additions and 6 deletions

View file

@ -16,10 +16,22 @@ struct JPEGLoadingContext;
// For the specification, see: https://www.w3.org/Graphics/JPEG/itu-t81.pdf
struct JPEGDecoderOptions {
enum class CMYK {
// For standalone jpeg files.
Normal,
// For jpeg data embedded in PDF files.
PDF,
};
CMYK cmyk { CMYK::Normal };
};
class JPEGImageDecoderPlugin : public ImageDecoderPlugin {
public:
static bool sniff(ReadonlyBytes);
static ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> create(ReadonlyBytes);
static ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> create_with_options(ReadonlyBytes, JPEGDecoderOptions = {});
virtual ~JPEGImageDecoderPlugin() override;
virtual IntSize size() override;