mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
PixelPaint: Move saving a project from Image into ImageEditor
The ImageEditor knows more about the image than Image itself. So to save a project with all the information known to the program about an image it's logical that ImageEditor performs that task rather than the Image. There isn't any additional data added yet, but now there's the possibility to do so.
This commit is contained in:
parent
60e526fdd2
commit
e867e4b84b
5 changed files with 21 additions and 19 deletions
|
@ -231,23 +231,6 @@ void Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json) const
|
|||
}
|
||||
}
|
||||
|
||||
Result<void, String> Image::write_to_fd_and_close(int fd) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
JsonObjectSerializer json(builder);
|
||||
serialize_as_json(json);
|
||||
json.finish();
|
||||
|
||||
auto file = Core::File::construct();
|
||||
file->open(fd, Core::OpenMode::WriteOnly | Core::OpenMode::Truncate, Core::File::ShouldCloseFileDescriptor::Yes);
|
||||
if (file->has_error())
|
||||
return String { file->error_string() };
|
||||
|
||||
if (!file->write(builder.string_view()))
|
||||
return String { file->error_string() };
|
||||
return {};
|
||||
}
|
||||
|
||||
Result<void, String> Image::write_to_file(const String& file_path) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue