Fixes for upside-down DIBs.
This commit is contained in:
parent
251ed43b98
commit
608629bc13
|
@ -74,7 +74,7 @@ static BOOL MFDRV_CreatePatternBrush(DC *dc, HBRUSH16 hBrush,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bmSize = bm.bmHeight * DIB_GetDIBWidthBytes(bm.bmWidth, 1);
|
bmSize = DIB_GetDIBImageBytes(bm.bmWidth, bm.bmHeight, 1);
|
||||||
|
|
||||||
len = sizeof(METARECORD) + sizeof(WORD) + sizeof(BITMAPINFO) +
|
len = sizeof(METARECORD) + sizeof(WORD) + sizeof(BITMAPINFO) +
|
||||||
sizeof(RGBQUAD) + bmSize;
|
sizeof(RGBQUAD) + bmSize;
|
||||||
|
@ -106,9 +106,9 @@ static BOOL MFDRV_CreatePatternBrush(DC *dc, HBRUSH16 hBrush,
|
||||||
if (info->bmiHeader.biCompression)
|
if (info->bmiHeader.biCompression)
|
||||||
bmSize = info->bmiHeader.biSizeImage;
|
bmSize = info->bmiHeader.biSizeImage;
|
||||||
else
|
else
|
||||||
bmSize = DIB_GetDIBWidthBytes(info->bmiHeader.biWidth,
|
bmSize = DIB_GetDIBImageBytes(info->bmiHeader.biWidth,
|
||||||
info->bmiHeader.biBitCount)
|
info->bmiHeader.biHeight,
|
||||||
* info->bmiHeader.biHeight;
|
info->bmiHeader.biBitCount);
|
||||||
biSize = DIB_BitmapInfoSize(info, LOWORD(logbrush->lbColor));
|
biSize = DIB_BitmapInfoSize(info, LOWORD(logbrush->lbColor));
|
||||||
len = sizeof(METARECORD) + biSize + bmSize + 2;
|
len = sizeof(METARECORD) + biSize + bmSize + 2;
|
||||||
mr = HeapAlloc(SystemHeap, HEAP_ZERO_MEMORY, len);
|
mr = HeapAlloc(SystemHeap, HEAP_ZERO_MEMORY, len);
|
||||||
|
|
|
@ -1880,8 +1880,9 @@ INT X11DRV_DIB_GetDIBits(
|
||||||
LeaveCriticalSection( &X11DRV_CritSection );
|
LeaveCriticalSection( &X11DRV_CritSection );
|
||||||
|
|
||||||
if(info->bmiHeader.biSizeImage == 0) /* Fill in biSizeImage */
|
if(info->bmiHeader.biSizeImage == 0) /* Fill in biSizeImage */
|
||||||
info->bmiHeader.biSizeImage = info->bmiHeader.biHeight *
|
info->bmiHeader.biSizeImage = DIB_GetDIBImageBytes(
|
||||||
DIB_GetDIBWidthBytes( info->bmiHeader.biWidth,
|
info->bmiHeader.biWidth,
|
||||||
|
info->bmiHeader.biHeight,
|
||||||
info->bmiHeader.biBitCount );
|
info->bmiHeader.biBitCount );
|
||||||
|
|
||||||
if(bbits - (BYTE *)bits > info->bmiHeader.biSizeImage)
|
if(bbits - (BYTE *)bits > info->bmiHeader.biSizeImage)
|
||||||
|
|
|
@ -55,6 +55,7 @@ extern HBITMAP BITMAP_CopyBitmap( HBITMAP hbitmap );
|
||||||
|
|
||||||
/* objects/dib.c */
|
/* objects/dib.c */
|
||||||
extern int DIB_GetDIBWidthBytes( int width, int depth );
|
extern int DIB_GetDIBWidthBytes( int width, int depth );
|
||||||
|
extern int DIB_GetDIBImageBytes( int width, int height, int depth );
|
||||||
extern int DIB_BitmapInfoSize( BITMAPINFO * info, WORD coloruse );
|
extern int DIB_BitmapInfoSize( BITMAPINFO * info, WORD coloruse );
|
||||||
extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width,
|
extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width,
|
||||||
int *height, WORD *bpp, WORD *compr );
|
int *height, WORD *bpp, WORD *compr );
|
||||||
|
|
|
@ -114,9 +114,9 @@ HBRUSH16 WINAPI CreateDIBPatternBrush16( HGLOBAL16 hbitmap, UINT16 coloruse )
|
||||||
if (info->bmiHeader.biCompression)
|
if (info->bmiHeader.biCompression)
|
||||||
size = info->bmiHeader.biSizeImage;
|
size = info->bmiHeader.biSizeImage;
|
||||||
else
|
else
|
||||||
size = DIB_GetDIBWidthBytes(info->bmiHeader.biWidth,
|
size = DIB_GetDIBImageBytes(info->bmiHeader.biWidth,
|
||||||
info->bmiHeader.biBitCount) *
|
info->bmiHeader.biHeight,
|
||||||
info->bmiHeader.biHeight;
|
info->bmiHeader.biBitCount);
|
||||||
size += DIB_BitmapInfoSize( info, coloruse );
|
size += DIB_BitmapInfoSize( info, coloruse );
|
||||||
|
|
||||||
if (!(logbrush.lbHatch = (INT16)GlobalAlloc16( GMEM_MOVEABLE, size )))
|
if (!(logbrush.lbHatch = (INT16)GlobalAlloc16( GMEM_MOVEABLE, size )))
|
||||||
|
@ -164,9 +164,9 @@ HBRUSH WINAPI CreateDIBPatternBrush(
|
||||||
if (info->bmiHeader.biCompression)
|
if (info->bmiHeader.biCompression)
|
||||||
size = info->bmiHeader.biSizeImage;
|
size = info->bmiHeader.biSizeImage;
|
||||||
else
|
else
|
||||||
size = DIB_GetDIBWidthBytes(info->bmiHeader.biWidth,
|
size = DIB_GetDIBImageBytes(info->bmiHeader.biWidth,
|
||||||
info->bmiHeader.biBitCount) *
|
info->bmiHeader.biHeight,
|
||||||
info->bmiHeader.biHeight;
|
info->bmiHeader.biBitCount);
|
||||||
size += DIB_BitmapInfoSize( info, coloruse );
|
size += DIB_BitmapInfoSize( info, coloruse );
|
||||||
|
|
||||||
if (!(logbrush.lbHatch = (INT)GlobalAlloc16( GMEM_MOVEABLE, size )))
|
if (!(logbrush.lbHatch = (INT)GlobalAlloc16( GMEM_MOVEABLE, size )))
|
||||||
|
@ -204,7 +204,8 @@ HBRUSH WINAPI CreateDIBPatternBrushPt(
|
||||||
BITMAPINFO *newInfo;
|
BITMAPINFO *newInfo;
|
||||||
INT size;
|
INT size;
|
||||||
|
|
||||||
TRACE(gdi, "%p\n", info );
|
TRACE(gdi, "%p %ldx%ld %dbpp\n", info, info->bmiHeader.biWidth,
|
||||||
|
info->bmiHeader.biHeight, info->bmiHeader.biBitCount);
|
||||||
|
|
||||||
/* Make a copy of the bitmap */
|
/* Make a copy of the bitmap */
|
||||||
|
|
||||||
|
@ -212,9 +213,9 @@ HBRUSH WINAPI CreateDIBPatternBrushPt(
|
||||||
if (info->bmiHeader.biCompression)
|
if (info->bmiHeader.biCompression)
|
||||||
size = info->bmiHeader.biSizeImage;
|
size = info->bmiHeader.biSizeImage;
|
||||||
else
|
else
|
||||||
size = DIB_GetDIBWidthBytes(info->bmiHeader.biWidth,
|
size = DIB_GetDIBImageBytes(info->bmiHeader.biWidth,
|
||||||
info->bmiHeader.biBitCount) *
|
info->bmiHeader.biHeight,
|
||||||
info->bmiHeader.biHeight;
|
info->bmiHeader.biBitCount);
|
||||||
size += DIB_BitmapInfoSize( info, coloruse );
|
size += DIB_BitmapInfoSize( info, coloruse );
|
||||||
|
|
||||||
if (!(logbrush.lbHatch = (INT)GlobalAlloc16( GMEM_MOVEABLE, size )))
|
if (!(logbrush.lbHatch = (INT)GlobalAlloc16( GMEM_MOVEABLE, size )))
|
||||||
|
|
|
@ -524,8 +524,9 @@ static HGLOBAL16 CURSORICON_CreateFromResource( HINSTANCE16 hInstance, HGLOBAL16
|
||||||
CBM_INIT, (char*)bmi + size, pInfo, DIB_RGB_COLORS );
|
CBM_INIT, (char*)bmi + size, pInfo, DIB_RGB_COLORS );
|
||||||
if( hXorBits )
|
if( hXorBits )
|
||||||
{
|
{
|
||||||
char* bits = (char *)bmi + size + bmi->bmiHeader.biHeight *
|
char* bits = (char *)bmi + size +
|
||||||
DIB_GetDIBWidthBytes(bmi->bmiHeader.biWidth,
|
DIB_GetDIBImageBytes(bmi->bmiHeader.biWidth,
|
||||||
|
bmi->bmiHeader.biHeight,
|
||||||
bmi->bmiHeader.biBitCount) / 2;
|
bmi->bmiHeader.biBitCount) / 2;
|
||||||
|
|
||||||
pInfo->bmiHeader.biBitCount = 1;
|
pInfo->bmiHeader.biBitCount = 1;
|
||||||
|
|
|
@ -40,6 +40,16 @@ int DIB_GetDIBWidthBytes( int width, int depth )
|
||||||
return 4 * words;
|
return 4 * words;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* DIB_GetDIBImageBytes
|
||||||
|
*
|
||||||
|
* Return the number of bytes used to hold the image in a DIB bitmap.
|
||||||
|
*/
|
||||||
|
int DIB_GetDIBImageBytes( int width, int height, int depth )
|
||||||
|
{
|
||||||
|
return DIB_GetDIBWidthBytes( width, depth ) * abs( height );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* DIB_BitmapInfoSize
|
* DIB_BitmapInfoSize
|
||||||
|
@ -537,15 +547,17 @@ INT WINAPI GetDIBits(
|
||||||
info->bmiHeader.biHeight = bmp->bitmap.bmHeight;
|
info->bmiHeader.biHeight = bmp->bitmap.bmHeight;
|
||||||
info->bmiHeader.biPlanes = 1;
|
info->bmiHeader.biPlanes = 1;
|
||||||
info->bmiHeader.biBitCount = bmp->bitmap.bmBitsPixel;
|
info->bmiHeader.biBitCount = bmp->bitmap.bmBitsPixel;
|
||||||
info->bmiHeader.biSizeImage = bmp->bitmap.bmHeight *
|
info->bmiHeader.biSizeImage =
|
||||||
DIB_GetDIBWidthBytes( bmp->bitmap.bmWidth,
|
DIB_GetDIBImageBytes( bmp->bitmap.bmWidth,
|
||||||
|
bmp->bitmap.bmHeight,
|
||||||
bmp->bitmap.bmBitsPixel );
|
bmp->bitmap.bmBitsPixel );
|
||||||
info->bmiHeader.biCompression = 0;
|
info->bmiHeader.biCompression = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info->bmiHeader.biSizeImage = info->bmiHeader.biHeight *
|
info->bmiHeader.biSizeImage = DIB_GetDIBImageBytes(
|
||||||
DIB_GetDIBWidthBytes( info->bmiHeader.biWidth,
|
info->bmiHeader.biWidth,
|
||||||
|
info->bmiHeader.biHeight,
|
||||||
info->bmiHeader.biBitCount );
|
info->bmiHeader.biBitCount );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue