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

PixelPaint: Save and load to and from disk

Store a PixelPaint project in a .pp file (as there doesn't seem to
be any real standard on this). It's a very simple json file that
contains the bitmap as a base64 encoded bmp.
This commit is contained in:
BenJilks 2020-10-18 14:44:33 +00:00 committed by Andreas Kling
parent 216385084b
commit d8474d80f2
4 changed files with 94 additions and 4 deletions

View file

@ -115,11 +115,20 @@ int main(int argc, char** argv)
if (!open_path.has_value())
return;
auto bitmap = Gfx::Bitmap::load_from_file(open_path.value());
if (!bitmap) {
GUI::MessageBox::show(window, String::formatted("Failed to load '{}'", open_path.value()), "Open failed", GUI::MessageBox::Type::Error);
auto image = PixelPaint::Image::create_from_file(open_path.value());
image_editor.set_image(image);
layer_list_widget.set_image(image);
}));
app_menu.add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
if (!image_editor.image())
return;
}
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, "untitled", "pp");
if (!save_path.has_value())
return;
image_editor.image()->save(save_path.value());
}));
app_menu.add_separator();
app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {