mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
PixelPaint: Encode layers in PixelPaint project files as PNG
Previously layers weren't compressed at all and the file size could go up really fast in a project with multiple layers. By switching to PNG, the situation is slightly better now. Interestingly enough, this change won't break compatibility with old files, as PixelPaint loads layers using ImageDecoder which will try every codec possible. :^)
This commit is contained in:
parent
11377bf0f8
commit
5049b103c0
Notes:
sideshowbarker
2024-07-17 03:03:48 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/5049b103c0 Pull-request: https://github.com/SerenityOS/serenity/pull/16551
1 changed files with 2 additions and 3 deletions
|
@ -128,7 +128,6 @@ ErrorOr<void> Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json
|
|||
{
|
||||
auto json_layers = TRY(json.add_array("layers"sv));
|
||||
for (auto const& layer : m_layers) {
|
||||
Gfx::BMPWriter bmp_writer;
|
||||
auto json_layer = TRY(json_layers.add_object());
|
||||
TRY(json_layer.add("width"sv, layer.size().width()));
|
||||
TRY(json_layer.add("height"sv, layer.size().height()));
|
||||
|
@ -138,9 +137,9 @@ ErrorOr<void> Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json
|
|||
TRY(json_layer.add("opacity_percent"sv, layer.opacity_percent()));
|
||||
TRY(json_layer.add("visible"sv, layer.is_visible()));
|
||||
TRY(json_layer.add("selected"sv, layer.is_selected()));
|
||||
TRY(json_layer.add("bitmap"sv, encode_base64(bmp_writer.dump(layer.content_bitmap()))));
|
||||
TRY(json_layer.add("bitmap"sv, encode_base64(TRY(Gfx::PNGWriter::encode(layer.content_bitmap())))));
|
||||
if (layer.is_masked())
|
||||
TRY(json_layer.add("mask"sv, encode_base64(bmp_writer.dump(*layer.mask_bitmap()))));
|
||||
TRY(json_layer.add("mask"sv, encode_base64(TRY(Gfx::PNGWriter::encode(*layer.mask_bitmap())))));
|
||||
TRY(json_layer.finish());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue