diff options
Diffstat (limited to 'Applications/PixelPaint/Image.cpp')
-rw-r--r-- | Applications/PixelPaint/Image.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Applications/PixelPaint/Image.cpp b/Applications/PixelPaint/Image.cpp index 57f83d7a9a..23a7f89d7e 100644 --- a/Applications/PixelPaint/Image.cpp +++ b/Applications/PixelPaint/Image.cpp @@ -32,7 +32,7 @@ #include <AK/JsonValue.h> #include <AK/StringBuilder.h> #include <LibGUI/Painter.h> -#include <LibGfx/BMPDumper.h> +#include <LibGfx/BMPWriter.h> #include <LibGfx/ImageDecoder.h> #include <stdio.h> @@ -118,7 +118,7 @@ void Image::save(const String& file_path) const { auto json_layers = json.add_array("layers"); for (const auto& layer : m_layers) { - Gfx::BMPDumper bmp_dumber; + Gfx::BMPWriter bmp_dumber; auto json_layer = json_layers.add_object(); json_layer.add("width", layer.size().width()); json_layer.add("height", layer.size().height()); @@ -140,6 +140,19 @@ void Image::save(const String& file_path) const fclose(file); } +void Image::export_bmp(const String& file_path) +{ + auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, m_size); + GUI::Painter painter(*bitmap); + paint_into(painter, { 0, 0, m_size.width(), m_size.height() }); + + Gfx::BMPWriter dumper; + auto bmp = dumper.dump(bitmap); + auto file = fopen(file_path.characters(), "wb"); + fwrite(bmp.data(), sizeof(u8), bmp.size(), file); + fclose(file); +} + void Image::add_layer(NonnullRefPtr<Layer> layer) { for (auto& existing_layer : m_layers) { |