1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 16:35:06 +00:00
serenity/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.h
Lucas CHOLLET ff6d82c3e7 LibGfx/PNG: Decode the header in create() and remove initialize()
This is done as a part of #19893. As `create()` is now the last user of
`decode_png_ihdr()`, we can easily make it return an `ErrorOr`.
2023-07-17 06:49:03 +01:00

39 lines
1 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGfx/ImageFormats/ImageDecoder.h>
namespace Gfx {
struct PNGLoadingContext;
class PNGImageDecoderPlugin final : public ImageDecoderPlugin {
public:
static bool sniff(ReadonlyBytes);
static ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> create(ReadonlyBytes);
virtual ~PNGImageDecoderPlugin() override;
virtual IntSize size() override;
virtual bool is_animated() override;
virtual size_t loop_count() override;
virtual size_t frame_count() override;
virtual size_t first_animated_frame_index() override;
virtual ErrorOr<ImageFrameDescriptor> frame(size_t index, Optional<IntSize> ideal_size = {}) override;
virtual ErrorOr<Optional<ReadonlyBytes>> icc_data() override;
private:
PNGImageDecoderPlugin(u8 const*, size_t);
bool ensure_image_data_chunk_was_decoded();
bool ensure_animation_frame_was_decoded(u32);
OwnPtr<PNGLoadingContext> m_context;
};
}