Commit 720bc3fa authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

gdi32: Handle BITMAP_CopyBitmap correctly for negative heights.

parent 005915f4
...@@ -512,15 +512,18 @@ HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap) ...@@ -512,15 +512,18 @@ HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap)
{ {
HBITMAP res; HBITMAP res;
DIBSECTION dib; DIBSECTION dib;
DWORD size; BITMAPOBJ *bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP );
if (!(size = GetObjectW( hbitmap, sizeof(dib), &dib ))) return 0;
if (size == sizeof(DIBSECTION)) if (!bmp) return 0;
if (bmp->dib)
{ {
void *bits; void *bits;
BITMAPINFO *bi; BITMAPINFO *bi;
HDC dc = CreateCompatibleDC( NULL ); HDC dc;
dib = *bmp->dib;
GDI_ReleaseObj( hbitmap );
dc = CreateCompatibleDC( NULL );
if (!dc) return 0; if (!dc) return 0;
if (!(bi = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] )))) if (!(bi = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] ))))
...@@ -532,6 +535,7 @@ HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap) ...@@ -532,6 +535,7 @@ HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap)
/* Get the color table or the color masks */ /* Get the color table or the color masks */
GetDIBits( dc, hbitmap, 0, 0, NULL, bi, DIB_RGB_COLORS ); GetDIBits( dc, hbitmap, 0, 0, NULL, bi, DIB_RGB_COLORS );
bi->bmiHeader.biHeight = dib.dsBmih.biHeight;
res = CreateDIBSection( dc, bi, DIB_RGB_COLORS, &bits, NULL, 0 ); res = CreateDIBSection( dc, bi, DIB_RGB_COLORS, &bits, NULL, 0 );
if (res) SetDIBits( dc, res, 0, dib.dsBm.bmHeight, dib.dsBm.bmBits, bi, DIB_RGB_COLORS ); if (res) SetDIBits( dc, res, 0, dib.dsBm.bmHeight, dib.dsBm.bmBits, bi, DIB_RGB_COLORS );
...@@ -539,13 +543,16 @@ HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap) ...@@ -539,13 +543,16 @@ HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap)
DeleteDC( dc ); DeleteDC( dc );
return res; return res;
} }
dib.dsBm = bmp->bitmap;
dib.dsBm.bmBits = NULL;
GDI_ReleaseObj( hbitmap );
res = CreateBitmapIndirect( &dib.dsBm ); res = CreateBitmapIndirect( &dib.dsBm );
if(res) { if(res) {
char *buf = HeapAlloc( GetProcessHeap(), 0, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight ); char *buf = HeapAlloc( GetProcessHeap(), 0, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight );
GetBitmapBits (hbitmap, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight, buf); GetBitmapBits (hbitmap, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight, buf);
SetBitmapBits (res, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight, buf); SetBitmapBits (res, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight, buf);
HeapFree( GetProcessHeap(), 0, buf ); HeapFree( GetProcessHeap(), 0, buf );
} }
return res; return res;
} }
......
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