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

LibGfx: Use ceil_div() in png decoder

No behavior change, arguably easier to read.
This commit is contained in:
Nico Weber 2023-11-16 20:00:52 -05:00 committed by Andreas Kling
parent 5a70813d11
commit 574357ef00

View file

@ -416,7 +416,7 @@ NEVER_INLINE FLATTEN static ErrorOr<void> unfilter(PNGLoadingContext& context)
// (three samples, two bytes per sample); for color type 0 with a bit depth of 2,
// bpp is equal to 1 (rounding up); for color type 4 with a bit depth of 16, bpp
// is equal to 4 (two-byte grayscale sample, plus two-byte alpha sample)."
u8 bytes_per_complete_pixel = (context.bit_depth + 7) / 8 * context.channels;
u8 bytes_per_complete_pixel = ceil_div(context.bit_depth, (u8)8) * context.channels;
u8 dummy_scanline_bytes[bytes_per_scanline];
memset(dummy_scanline_bytes, 0, sizeof(dummy_scanline_bytes));