mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +00:00
LibGfx/ICO: Do not try to decode a mask if we already reached EOF
When using the BMP encoding, ICO images are expected to contain a 1-bit mask for transparency. Regardless an alpha channel is already included in the image, the mask is always required. As stated here[1], the mask is used to provide shadow around the image. Unfortunately, it seems that some encoder do not include that second transparency mask. So let's read that mask only if some data is still remaining after decoding the image. The test case has been generated by truncating the 64 last bytes (originally dedicated to the mask) from the `serenity.ico` file and changing the declared size of the image in the ICO header. The size value is stored at the offset 0x0E in the file and I changed the value from 0x0468 to 0x0428. [1]: https://devblogs.microsoft.com/oldnewthing/20101021-00/?p=12483
This commit is contained in:
parent
9c54c13744
commit
402de2985d
3 changed files with 13 additions and 2 deletions
|
@ -1429,7 +1429,7 @@ static ErrorOr<void> decode_bmp_pixel_data(BMPLoadingContext& context)
|
|||
TRY(process_row(row));
|
||||
}
|
||||
|
||||
if (context.is_included_in_ico) {
|
||||
if (context.is_included_in_ico && !streamer.at_end()) {
|
||||
for (u32 row = 0; row < height; ++row) {
|
||||
TRY(process_mask_row(row));
|
||||
}
|
||||
|
@ -1440,7 +1440,7 @@ static ErrorOr<void> decode_bmp_pixel_data(BMPLoadingContext& context)
|
|||
TRY(process_row(row));
|
||||
}
|
||||
|
||||
if (context.is_included_in_ico) {
|
||||
if (context.is_included_in_ico && !streamer.at_end()) {
|
||||
for (i32 row = height - 1; row >= 0; --row) {
|
||||
TRY(process_mask_row(row));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue