From e8788d40232692d1736ce8391e8b18b05a3e465b Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 31 Jan 2024 20:35:49 -0500 Subject: [PATCH] LibGfx/JPEGWriter: Move image data writing into new add_image() function No behavior change. --- .../Libraries/LibGfx/ImageFormats/JPEGWriter.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp b/Userland/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp index 12a378ce4cf..cea9b8e141a 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp @@ -547,19 +547,22 @@ ErrorOr add_headers(Stream& stream, JPEGEncodingContext& context, JPEGWrit return {}; } +ErrorOr add_image(Stream& stream, JPEGEncodingContext& context) +{ + context.fdct_and_quantization(); + TRY(context.write_huffman_stream()); + TRY(add_end_of_image(stream)); + return {}; +} + } ErrorOr JPEGWriter::encode(Stream& stream, Bitmap const& bitmap, Options const& options) { JPEGEncodingContext context { JPEGBigEndianOutputBitStream { stream } }; TRY(add_headers(stream, context, options, bitmap.size())); - TRY(context.initialize_mcu(bitmap)); - context.fdct_and_quantization(); - - TRY(context.write_huffman_stream()); - - TRY(add_end_of_image(stream)); + TRY(add_image(stream, context)); return {}; }