1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 03:27:44 +00:00

LibGfx: Improve PNG encoder API somewhat

This is still far from ideal, but let's at least make it take a
Gfx::Bitmap const&.
This commit is contained in:
Andreas Kling 2021-04-19 23:43:04 +02:00
parent 51fe25fdbb
commit 6793574003
4 changed files with 31 additions and 30 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, Pierre Hoffmeister
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -26,9 +27,8 @@
#pragma once
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Forward.h>
namespace Gfx {
@ -36,14 +36,16 @@ class PNGChunk;
class PNGWriter {
public:
ByteBuffer write(const RefPtr<Bitmap>);
static ByteBuffer encode(Gfx::Bitmap const&);
private:
PNGWriter() { }
Vector<u8> m_data;
void add_chunk(const PNGChunk&);
void add_chunk(PNGChunk const&);
void add_png_header();
void add_IHDR_chunk(u32 width, u32 height, u8 bit_depth, u8 color_type, u8 compression_method, u8 filter_method, u8 interlace_method);
void add_IDAT_chunk(const RefPtr<Bitmap>);
void add_IDAT_chunk(Gfx::Bitmap const&);
void add_IEND_chunk();
};