1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 15:48:11 +00:00

LibGfx: Add BMP loader

Adds an *almost fully featured BMP loader to process .bmp files.

Features:
- All header formats are supported
- Full RLE4/8/24 support
- Color scaling (e.g. distributing a 5-bit color throughout the 8-bit
color spectrum, so 5-bit white is still 0xffffff)
- Full BITMASK/ALPHABITMASK support

*Not included:
- 1D Huffman compression. Good luck actually finding a bmp in the wild
that uses this
- Use of any field in the V4/V5 header. Color spaces? Endpoints? No
thanks :)

This loader was tested with the images at
https://entropymine.com/jason/bmpsuite/bmpsuite/html/bmpsuite.html. This
loader correctly displays 81 out of the 90 total images (for reference,
firefox displays 64 correctly). Note that not rendering the images at
the bottom is counted as displaying correctly.
This commit is contained in:
Matthew Olsson 2020-06-17 12:37:16 -07:00 committed by Andreas Kling
parent dfe5b232f4
commit 4e093a7c23
8 changed files with 1477 additions and 15 deletions

View file

@ -83,6 +83,8 @@ static String guess_mime_type_based_on_filename(const URL& url)
return "image/png";
if (url.path().ends_with(".gif"))
return "image/gif";
if (url.path().ends_with(".bmp"))
return "image/bmp";
if (url.path().ends_with(".md"))
return "text/markdown";
if (url.path().ends_with(".html") || url.path().ends_with(".htm"))