Commit 162d95a3 authored by Alexandre Julliard's avatar Alexandre Julliard

Fix the bitmap info size computation when masks are present.

parent 91948f9c
...@@ -123,7 +123,7 @@ int DIB_GetDIBImageBytes( int width, int height, int depth ) ...@@ -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 ) ...@@ -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));
} }
} }
......
...@@ -304,7 +304,7 @@ static int get_dib_width_bytes( int width, int depth ) ...@@ -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 ) ...@@ -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));
} }
} }
......
...@@ -193,7 +193,7 @@ static int X11DRV_DIB_GetDIBImageBytes( int width, int height, int depth ) ...@@ -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 ) ...@@ -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));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment