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:
parent
44a5558525
commit
be4913c1fb
3 changed files with 26 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue