diff options
author | Tobias Christiansen <tobyase@serenityos.org> | 2021-08-31 20:24:46 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-04 03:29:09 +0200 |
commit | 60e526fdd2ab644d2c18357f299873ae51134448 (patch) | |
tree | c685a0b33cf1940a241f06dd21360709922fc1fd /Userland/Applications/PixelPaint/Image.h | |
parent | d81ba98976c68c52ead7feb5ce352797ddca6b68 (diff) | |
download | serenity-60e526fdd2ab644d2c18357f299873ae51134448.zip |
PixelPaint: Move serialization of Image into seperate function
This eliminates duplicated code.
Diffstat (limited to 'Userland/Applications/PixelPaint/Image.h')
-rw-r--r-- | Userland/Applications/PixelPaint/Image.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Applications/PixelPaint/Image.h b/Userland/Applications/PixelPaint/Image.h index b681c10c13..f83ed2ce18 100644 --- a/Userland/Applications/PixelPaint/Image.h +++ b/Userland/Applications/PixelPaint/Image.h @@ -1,6 +1,7 @@ /* * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org> * Copyright (c) 2021, Mustafa Quraish <mustafa@cs.toronto.edu> + * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -8,6 +9,7 @@ #pragma once #include <AK/HashTable.h> +#include <AK/JsonObjectSerializer.h> #include <AK/NonnullRefPtrVector.h> #include <AK/RefCounted.h> #include <AK/RefPtr.h> @@ -47,6 +49,7 @@ public: static Result<NonnullRefPtr<Image>, String> try_create_from_fd_and_close(int fd, String const& file_path); static Result<NonnullRefPtr<Image>, String> try_create_from_path(String const& file_path); static RefPtr<Image> try_create_from_bitmap(NonnullRefPtr<Gfx::Bitmap>); + static Result<NonnullRefPtr<Image>, String> try_create_from_pixel_paint_json(JsonObject const&); // This generates a new Bitmap with the final image (all layers composed according to their attributes.) RefPtr<Gfx::Bitmap> try_compose_bitmap(Gfx::BitmapFormat format) const; @@ -63,6 +66,8 @@ public: void restore_snapshot(Image const&); void paint_into(GUI::Painter&, Gfx::IntRect const& dest_rect) const; + + void serialize_as_json(JsonObjectSerializer<StringBuilder>& json) const; Result<void, String> write_to_fd_and_close(int fd) const; Result<void, String> write_to_file(String const& file_path) const; Result<void, String> export_bmp_to_fd_and_close(int fd, bool preserve_alpha_channel); |