Fix the bitmap info size computation when masks are present.

This commit is contained in:
Alexandre Julliard 2010-05-14 17:17:46 +02:00
parent 91948f9ce8
commit 162d95a3ce
3 changed files with 9 additions and 9 deletions

View File

@ -123,7 +123,7 @@ int DIB_GetDIBImageBytes( int width, int height, int depth )
*/ */
int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) 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)) 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)) if (!colors && (info->bmiHeader.biBitCount <= 8))
colors = 1 << info->bmiHeader.biBitCount; colors = 1 << info->bmiHeader.biBitCount;
if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3; if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3;
return info->bmiHeader.biSize + masks * sizeof(DWORD) + colors * size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) );
((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD)); return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD));
} }
} }

View File

@ -304,7 +304,7 @@ static int get_dib_width_bytes( int width, int depth )
*/ */
static int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) 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)) 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)) if (!colors && (info->bmiHeader.biBitCount <= 8))
colors = 1 << info->bmiHeader.biBitCount; colors = 1 << info->bmiHeader.biBitCount;
if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3; if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3;
return info->bmiHeader.biSize + masks * sizeof(DWORD) + colors * size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) );
((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD)); return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD));
} }
} }

View File

@ -193,7 +193,7 @@ static int X11DRV_DIB_GetDIBImageBytes( int width, int height, int depth )
*/ */
int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) 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)) 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)) if (!colors && (info->bmiHeader.biBitCount <= 8))
colors = 1 << info->bmiHeader.biBitCount; colors = 1 << info->bmiHeader.biBitCount;
if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3; if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3;
return info->bmiHeader.biSize + masks * sizeof(DWORD) + colors * size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) );
((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD)); return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD));
} }
} }