Alexandre Julliard : Fix the bitmap info size computation when masks are present.
Alexandre Julliard
julliard at winehq.org
Fri May 14 11:17:28 CDT 2010
Module: wine
Branch: master
Commit: 162d95a3cea74ce2a25f3af02a8ad935e85d66ae
URL: http://source.winehq.org/git/wine.git/?a=commit;h=162d95a3cea74ce2a25f3af02a8ad935e85d66ae
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri May 14 17:17:46 2010 +0200
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 1b34a34..b19cb9d 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 96827c2..8cccbbe 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 95e3511..cf58e8b 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));
}
}
More information about the wine-cvs
mailing list