Fix the bitmap info size computation when masks are present.
This commit is contained in:
parent
91948f9ce8
commit
162d95a3ce
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue