mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:47:44 +00:00
LibGfx/PortableFormat+image: Make encode
take a Stream
As we directly write to the stream, we don't need to store a copy of the entire image in memory. However, writing to a stream is heavier on the CPU than to a ByteBuffer. This commit unfortunately makes `add_pixels` two times slower.
This commit is contained in:
parent
af6dc267d3
commit
d4d3c3f262
3 changed files with 29 additions and 28 deletions
|
@ -26,13 +26,13 @@ class PortableFormatWriter {
|
|||
public:
|
||||
using Options = PortableFormatWriterOptions;
|
||||
|
||||
static ErrorOr<ByteBuffer> encode(Bitmap const&, Options options = Options {});
|
||||
static ErrorOr<void> encode(Stream&, Bitmap const&, Options options = Options {});
|
||||
|
||||
private:
|
||||
PortableFormatWriter() = delete;
|
||||
|
||||
static ErrorOr<void> add_header(ByteBuffer&, Options const& options, u32 width, u32 height, u32 max_value);
|
||||
static ErrorOr<void> add_pixels(ByteBuffer&, Options const& options, Bitmap const&);
|
||||
static ErrorOr<void> add_header(Stream&, Options const& options, u32 width, u32 height, u32 max_value);
|
||||
static ErrorOr<void> add_pixels(Stream&, Options const& options, Bitmap const&);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue