LibGfx/JPEGWriter: Move image data writing into new add_image() function

No behavior change.
This commit is contained in:
Nico Weber 2024-01-31 20:35:49 -05:00 committed by Andreas Kling
parent e449dba85b
commit e8788d4023
Notes: sideshowbarker 2024-07-17 04:41:05 +09:00

View File

@ -547,19 +547,22 @@ ErrorOr<void> add_headers(Stream& stream, JPEGEncodingContext& context, JPEGWrit
return {};
}
ErrorOr<void> add_image(Stream& stream, JPEGEncodingContext& context)
{
context.fdct_and_quantization();
TRY(context.write_huffman_stream());
TRY(add_end_of_image(stream));
return {};
}
}
ErrorOr<void> 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 {};
}