mirror of
https://github.com/RGBCube/serenity
synced 2025-07-07 04:57:35 +00:00

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.
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
* Copyright (c) 2022-2023, Lucas Chollet <lucas.chollet@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/MemoryStream.h>
|
|
#include <LibGfx/ImageFormats/ImageDecoder.h>
|
|
|
|
namespace Gfx {
|
|
|
|
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;
|
|
|
|
virtual ErrorOr<ImageFrameDescriptor> frame(size_t index, Optional<IntSize> ideal_size = {}) override;
|
|
virtual ErrorOr<Optional<ReadonlyBytes>> icc_data() override;
|
|
|
|
private:
|
|
JPEGImageDecoderPlugin(NonnullOwnPtr<JPEGLoadingContext>);
|
|
|
|
NonnullOwnPtr<JPEGLoadingContext> m_context;
|
|
};
|
|
|
|
}
|