comctl32: Simplify the DIB byte width computation.
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c index 66cd03d..ec62370 100644 --- a/dlls/comctl32/imagelist.c +++ b/dlls/comctl32/imagelist.c
@@ -2061,41 +2061,13 @@ /*********************************************************************** - * DIB_GetDIBWidthBytes - * - * Return the width of a DIB bitmap in bytes. DIB bitmap data is 32-bit aligned. - */ -static int DIB_GetDIBWidthBytes( int width, int depth ) -{ - int words; - - switch(depth) - { - case 1: words = (width + 31) / 32; break; - case 4: words = (width + 7) / 8; break; - case 8: words = (width + 3) / 4; break; - case 15: - case 16: words = (width + 1) / 2; break; - case 24: words = (width * 3 + 3)/4; break; - - default: - WARN("(%d): Unsupported depth\n", depth ); - /* fall through */ - case 32: - words = width; - break; - } - return 4 * words; -} - -/*********************************************************************** * DIB_GetDIBImageBytes * * Return the number of bytes used to hold the image in a DIB bitmap. */ static int DIB_GetDIBImageBytes( int width, int height, int depth ) { - return DIB_GetDIBWidthBytes( width, depth ) * abs( height ); + return (((width * depth + 31) / 8) & ~3) * abs( height ); }
diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c index 46b3595..0441fd0 100644 --- a/dlls/comctl32/tests/imagelist.c +++ b/dlls/comctl32/tests/imagelist.c
@@ -738,24 +738,7 @@ static INT DIB_GetWidthBytes( int width, int bpp ) { - int words; - - switch (bpp) - { - case 1: words = (width + 31) / 32; break; - case 4: words = (width + 7) / 8; break; - case 8: words = (width + 3) / 4; break; - case 15: - case 16: words = (width + 1) / 2; break; - case 24: words = (width * 3 + 3)/4; break; - case 32: words = width; break; - - default: - trace("Unknown depth %d, please report.\n", bpp ); - assert(0); - return -1; - } - return 4 * words; + return ((width * bpp + 31) / 8) & ~3; } static void check_bitmap_data(const char *bm_data, ULONG bm_data_size,