1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

LibGfx: Use ReadonlyBytes in PNGChunk API

This commit is contained in:
Nico Weber 2023-03-15 10:55:57 +01:00 committed by Linus Groh
parent 71b7e65a52
commit 75895bc892

View file

@ -36,8 +36,7 @@ public:
ErrorOr<void> add_u8(u8);
template<typename T>
ErrorOr<void> add(T*, size_t);
ErrorOr<void> add(ReadonlyBytes);
ErrorOr<void> store_type();
void store_data_length();
@ -84,10 +83,9 @@ ErrorOr<void> PNGChunk::add(T data)
return {};
}
template<typename T>
ErrorOr<void> PNGChunk::add(T* data, size_t size)
ErrorOr<void> PNGChunk::add(ReadonlyBytes bytes)
{
TRY(m_data.try_append(data, size));
TRY(m_data.try_append(bytes));
return {};
}
@ -266,7 +264,7 @@ ErrorOr<void> PNGWriter::add_IDAT_chunk(Gfx::Bitmap const& bitmap)
auto zlib_buffer = TRY(Compress::ZlibCompressor::compress_all(uncompressed_block_data, Compress::ZlibCompressionLevel::Best));
TRY(png_chunk.add(zlib_buffer.data(), zlib_buffer.size()));
TRY(png_chunk.add(zlib_buffer));
TRY(add_chunk(png_chunk));
return {};
}