diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index 6f5b3e8cd6..cd91702f1a 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -194,6 +194,11 @@ ErrorOr> Bitmap::try_create_with_anonymous_buffer(BitmapFo return adopt_nonnull_ref_or_enomem(new (nothrow) Bitmap(format, move(buffer), size, scale_factor, palette)); } +ErrorOr> Bitmap::try_create_from_serialized_byte_buffer(ByteBuffer&& buffer) +{ + return try_create_from_serialized_bytes(buffer.bytes()); +} + /// Read a bitmap as described by: /// - actual size /// - width @@ -203,9 +208,9 @@ ErrorOr> Bitmap::try_create_with_anonymous_buffer(BitmapFo /// - palette count /// - palette data (= palette count * BGRA8888) /// - image data (= actual size * u8) -ErrorOr> Bitmap::try_create_from_serialized_byte_buffer(ByteBuffer&& buffer) +ErrorOr> Bitmap::try_create_from_serialized_bytes(ReadonlyBytes bytes) { - InputMemoryStream stream { buffer }; + InputMemoryStream stream { bytes }; size_t actual_size; unsigned width; unsigned height; diff --git a/Userland/Libraries/LibGfx/Bitmap.h b/Userland/Libraries/LibGfx/Bitmap.h index c694634ce7..b1dcf9bb65 100644 --- a/Userland/Libraries/LibGfx/Bitmap.h +++ b/Userland/Libraries/LibGfx/Bitmap.h @@ -98,6 +98,7 @@ public: [[nodiscard]] static ErrorOr> try_load_from_file(StringView path, int scale_factor = 1); [[nodiscard]] static ErrorOr> try_load_from_fd_and_close(int fd, StringView path); [[nodiscard]] static ErrorOr> try_create_with_anonymous_buffer(BitmapFormat, Core::AnonymousBuffer, IntSize, int intrinsic_scale, Vector const& palette); + static ErrorOr> try_create_from_serialized_bytes(ReadonlyBytes); static ErrorOr> try_create_from_serialized_byte_buffer(ByteBuffer&&); static bool is_path_a_supported_image_format(StringView path)