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

LibCompress: Switch ZlibCompressor to a constructor pattern

We don't have anything fallible in the constructor yet, but what's there
should be fallible and once we switch to Core::Stream it will be
fallible.
This commit is contained in:
Tim Schumacher 2022-12-26 15:58:42 +01:00 committed by Sam Atkins
parent 23a9d62f39
commit f0b035b66c
3 changed files with 21 additions and 18 deletions

View file

@ -264,11 +264,7 @@ ErrorOr<void> PNGWriter::add_IDAT_chunk(Gfx::Bitmap const& bitmap)
TRY(uncompressed_block_data.try_append(best_filter.buffer));
}
auto maybe_zlib_buffer = Compress::ZlibCompressor::compress_all(uncompressed_block_data, Compress::ZlibCompressionLevel::Best);
if (!maybe_zlib_buffer.has_value()) {
return Error::from_string_literal("PNGWriter: ZlibCompressor failed");
}
auto zlib_buffer = maybe_zlib_buffer.release_value();
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(add_chunk(png_chunk));