1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:17:46 +00:00

LibGfx/BMPWriter: Add support for V3 & V4 DIB headers

This adds very simple support for storing BMP files with
BITMAPV3INFOHEADER and BITMAPV4HEADER. This in turn allows us to
store alpha channels which is nice for our .pp file format. For
the moment no data regarding colorspace is saved, only the bare
minimum to make a valid file.

Some small restructuring of the code is made to hopefully make it
easier to implement more DIB-headers and support for colorspace/gamma
correction in the future.
This commit is contained in:
Marcus Nilsson 2021-07-03 23:50:21 +02:00 committed by Andreas Kling
parent 9fe363eaad
commit 8324ffefe7
2 changed files with 68 additions and 30 deletions

View file

@ -16,16 +16,25 @@ class BMPWriter {
public:
BMPWriter() = default;
ByteBuffer dump(const RefPtr<Bitmap>);
enum class Compression : u32 {
RGB = 0,
BI_RGB = 0,
BI_BITFIELDS = 3,
};
enum class DibHeader : u32 {
Info = 40,
V3 = 56,
V4 = 108,
};
ByteBuffer dump(const RefPtr<Bitmap>, DibHeader dib_header = DibHeader::V4);
inline void set_compression(Compression compression) { m_compression = compression; }
private:
Compression m_compression { Compression::RGB };
Compression m_compression { Compression::BI_BITFIELDS };
int m_bytes_per_pixel { 4 };
bool m_include_alpha_channel { true };
};
}