From 162d95a3cea74ce2a25f3af02a8ad935e85d66ae Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 14 May 2010 17:17:46 +0200 Subject: [PATCH] Fix the bitmap info size computation when masks are present. --- dlls/gdi32/dib.c | 6 +++--- dlls/user32/cursoricon.c | 6 +++--- dlls/winex11.drv/dib.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c index 1b34a341043..b19cb9d47b3 100644 --- a/dlls/gdi32/dib.c +++ b/dlls/gdi32/dib.c @@ -123,7 +123,7 @@ int DIB_GetDIBImageBytes( int width, int height, int depth ) */ int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) { - int colors, masks = 0; + unsigned int colors, size, masks = 0; if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) { @@ -139,8 +139,8 @@ int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) if (!colors && (info->bmiHeader.biBitCount <= 8)) colors = 1 << info->bmiHeader.biBitCount; if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3; - return info->bmiHeader.biSize + masks * sizeof(DWORD) + colors * - ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD)); + size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) ); + return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD)); } } diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index 96827c26fa4..8cccbbe4adf 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -304,7 +304,7 @@ static int get_dib_width_bytes( int width, int depth ) */ static int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) { - int colors, masks = 0; + unsigned int colors, size, masks = 0; if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) { @@ -321,8 +321,8 @@ static int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) if (!colors && (info->bmiHeader.biBitCount <= 8)) colors = 1 << info->bmiHeader.biBitCount; if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3; - return info->bmiHeader.biSize + masks * sizeof(DWORD) + colors * - ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD)); + size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) ); + return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD)); } } diff --git a/dlls/winex11.drv/dib.c b/dlls/winex11.drv/dib.c index 95e3511791e..cf58e8bd1fc 100644 --- a/dlls/winex11.drv/dib.c +++ b/dlls/winex11.drv/dib.c @@ -193,7 +193,7 @@ static int X11DRV_DIB_GetDIBImageBytes( int width, int height, int depth ) */ int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) { - unsigned int colors, masks = 0; + unsigned int colors, size, masks = 0; if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) { @@ -208,8 +208,8 @@ int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) if (!colors && (info->bmiHeader.biBitCount <= 8)) colors = 1 << info->bmiHeader.biBitCount; if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3; - return info->bmiHeader.biSize + masks * sizeof(DWORD) + colors * - ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD)); + size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) ); + return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD)); } } -- 2.11.4.GIT