mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 14:25:08 +00:00

At the moment, this processes the RIFF chunk structure and extracts the ICCP chunk, so that `icc` can now print ICC profiles embedded in webp files. (And are image files really more than containers of icc profiles?) It doesn't even decode image dimensions yet. The lossy format is a VP8 video frame. Once we get to that, we might want to move all the image decoders into a new LibImageDecoders that depends on both LibGfx and LibVideo. (Other newer image formats like heic and av1f also use video frames for image data.)
38 lines
1 KiB
C++
38 lines
1 KiB
C++
/*
|
|
* Copyright (c) 2023, Nico Weber <thakis@chromium.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGfx/ImageDecoder.h>
|
|
|
|
namespace Gfx {
|
|
|
|
struct WebPLoadingContext;
|
|
|
|
class WebPImageDecoderPlugin final : public ImageDecoderPlugin {
|
|
public:
|
|
static ErrorOr<bool> sniff(ReadonlyBytes);
|
|
static ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> create(ReadonlyBytes);
|
|
|
|
virtual ~WebPImageDecoderPlugin() override;
|
|
|
|
virtual IntSize size() override;
|
|
virtual void set_volatile() override;
|
|
[[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
|
|
virtual bool initialize() override;
|
|
virtual bool is_animated() override;
|
|
virtual size_t loop_count() override;
|
|
virtual size_t frame_count() override;
|
|
virtual ErrorOr<ImageFrameDescriptor> frame(size_t index) override;
|
|
virtual ErrorOr<Optional<ReadonlyBytes>> icc_data() override;
|
|
|
|
private:
|
|
WebPImageDecoderPlugin(ReadonlyBytes, OwnPtr<WebPLoadingContext>);
|
|
|
|
OwnPtr<WebPLoadingContext> m_context;
|
|
};
|
|
|
|
}
|