2021-01-22 11:46:09 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Pierre Hoffmeister
|
2021-04-19 23:43:04 +02:00
|
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
2021-01-22 11:46:09 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-01-22 11:46:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/Vector.h>
|
2021-04-19 23:43:04 +02:00
|
|
|
#include <LibGfx/Forward.h>
|
2022-07-10 00:08:32 +02:00
|
|
|
#include <LibGfx/PNGShared.h>
|
2021-01-22 11:46:09 +01:00
|
|
|
|
|
|
|
|
namespace Gfx {
|
|
|
|
|
|
|
|
|
|
class PNGChunk;
|
|
|
|
|
|
|
|
|
|
class PNGWriter {
|
|
|
|
|
public:
|
2022-12-05 20:34:27 +01:00
|
|
|
static ErrorOr<ByteBuffer> encode(Gfx::Bitmap const&);
|
2021-01-22 11:46:09 +01:00
|
|
|
|
|
|
|
|
private:
|
2022-03-14 13:26:37 -06:00
|
|
|
PNGWriter() = default;
|
2021-04-19 23:43:04 +02:00
|
|
|
|
2021-01-22 11:46:09 +01:00
|
|
|
Vector<u8> m_data;
|
2021-07-11 21:33:37 +02:00
|
|
|
void add_chunk(PNGChunk&);
|
2021-01-22 11:46:09 +01:00
|
|
|
void add_png_header();
|
2022-07-10 00:08:32 +02:00
|
|
|
void add_IHDR_chunk(u32 width, u32 height, u8 bit_depth, PNG::ColorType color_type, u8 compression_method, u8 filter_method, u8 interlace_method);
|
2021-04-19 23:43:04 +02:00
|
|
|
void add_IDAT_chunk(Gfx::Bitmap const&);
|
2021-01-22 11:46:09 +01:00
|
|
|
void add_IEND_chunk();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|