From 574357ef009a6f06d3b1b92e3048da088dbe7696 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 16 Nov 2023 20:00:52 -0500 Subject: [PATCH] LibGfx: Use ceil_div() in png decoder No behavior change, arguably easier to read. --- Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp index ebf9ecc5d3..27b6915745 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/PNGLoader.cpp @@ -416,7 +416,7 @@ NEVER_INLINE FLATTEN static ErrorOr 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));