1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:58:13 +00:00

PixelPaint: Add exporting to the QOI image format

This commit is contained in:
Olivier De Canniere 2022-04-07 14:23:54 +02:00 committed by Linus Groh
parent 44a5558525
commit be4913c1fb
3 changed files with 26 additions and 0 deletions

View file

@ -19,6 +19,7 @@
#include <LibGfx/BMPWriter.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/PNGWriter.h>
#include <LibGfx/QOIWriter.h>
#include <LibImageDecoderClient/Client.h>
#include <stdio.h>
@ -212,6 +213,17 @@ ErrorOr<void> Image::export_png_to_file(Core::File& file, bool preserve_alpha_ch
return {};
}
ErrorOr<void> Image::export_qoi_to_file(Core::File& file) const
{
auto bitmap = TRY(try_compose_bitmap(Gfx::BitmapFormat::BGRA8888));
auto encoded_data = Gfx::QOIWriter::encode(bitmap);
if (!file.write(encoded_data.data(), encoded_data.size()))
return Error::from_errno(file.error());
return {};
}
void Image::add_layer(NonnullRefPtr<Layer> layer)
{
for (auto& existing_layer : m_layers) {