mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
LibGfx/JPEG: Take the quality as an argument instead of hardcoding it
This commit is contained in:
parent
05c8ad4e91
commit
a58c7fe322
2 changed files with 10 additions and 6 deletions
|
@ -475,14 +475,12 @@ ErrorOr<void> add_scan_header(Stream& stream)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> JPEGWriter::encode(Stream& stream, Bitmap const& bitmap)
|
ErrorOr<void> JPEGWriter::encode(Stream& stream, Bitmap const& bitmap, Options const& options)
|
||||||
{
|
{
|
||||||
JPEGEncodingContext context { JPEGBigEndianOutputBitStream { stream } };
|
JPEGEncodingContext context { JPEGBigEndianOutputBitStream { stream } };
|
||||||
|
|
||||||
// FIXME: Let's take the quality as an option instead of hardcoding it
|
context.set_luminance_quantization_table(s_default_luminance_quantization_table, options.quality);
|
||||||
// (there might also be a bug with quantization tables :^)).
|
context.set_chrominance_quantization_table(s_default_chrominance_quantization_table, options.quality);
|
||||||
context.set_luminance_quantization_table(s_default_luminance_quantization_table, 100);
|
|
||||||
context.set_chrominance_quantization_table(s_default_chrominance_quantization_table, 100);
|
|
||||||
|
|
||||||
context.dc_luminance_huffman_table = s_default_dc_luminance_huffman_table;
|
context.dc_luminance_huffman_table = s_default_dc_luminance_huffman_table;
|
||||||
context.dc_chrominance_huffman_table = s_default_dc_chrominance_huffman_table;
|
context.dc_chrominance_huffman_table = s_default_dc_chrominance_huffman_table;
|
||||||
|
|
|
@ -11,9 +11,15 @@
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
|
struct JPEGEncoderOptions {
|
||||||
|
u8 quality { 75 };
|
||||||
|
};
|
||||||
|
|
||||||
class JPEGWriter {
|
class JPEGWriter {
|
||||||
public:
|
public:
|
||||||
static ErrorOr<void> encode(Stream&, Bitmap const&);
|
using Options = JPEGEncoderOptions;
|
||||||
|
|
||||||
|
static ErrorOr<void> encode(Stream&, Bitmap const&, Options const& = {});
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JPEGWriter() = delete;
|
JPEGWriter() = delete;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue