diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index 9042b88e337..282e22b4a4b 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -510,59 +510,6 @@ LONG WINAPI SetBitmapBits( return count; } -/********************************************************************** - * BITMAP_CopyBitmap - * - */ -HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap) -{ - HBITMAP res; - DIBSECTION dib; - BITMAPOBJ *bmp = GDI_GetObjPtr( hbitmap, OBJ_BITMAP ); - - if (!bmp) return 0; - if (bmp->dib) - { - void *bits; - BITMAPINFO *bi; - HDC dc; - - dib = *bmp->dib; - GDI_ReleaseObj( hbitmap ); - dc = CreateCompatibleDC( NULL ); - - if (!dc) return 0; - if (!(bi = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] )))) - { - DeleteDC( dc ); - return 0; - } - bi->bmiHeader = dib.dsBmih; - - /* Get the color table or the color masks */ - 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 ); - if (res) SetDIBits( dc, res, 0, dib.dsBm.bmHeight, dib.dsBm.bmBits, bi, DIB_RGB_COLORS ); - HeapFree( GetProcessHeap(), 0, bi ); - DeleteDC( dc ); - return res; - } - dib.dsBm = bmp->bitmap; - dib.dsBm.bmBits = NULL; - GDI_ReleaseObj( hbitmap ); - - res = CreateBitmapIndirect( &dib.dsBm ); - if(res) { - char *buf = HeapAlloc( GetProcessHeap(), 0, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight ); - GetBitmapBits (hbitmap, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight, buf); - SetBitmapBits (res, dib.dsBm.bmWidthBytes * dib.dsBm.bmHeight, buf); - HeapFree( GetProcessHeap(), 0, buf ); - } - return res; -} - static void set_initial_bitmap_bits( HBITMAP hbitmap, BITMAPOBJ *bmp ) { diff --git a/dlls/gdi32/brush.c b/dlls/gdi32/brush.c index ccd13698248..579e9fd2096 100644 --- a/dlls/gdi32/brush.c +++ b/dlls/gdi32/brush.c @@ -99,8 +99,22 @@ static BOOL copy_bitmap( BRUSHOBJ *brush, HBITMAP bitmap ) if (!bmp->dib) { + if ((brush->bitmap = CreateBitmap( bmp->bitmap.bmWidth, bmp->bitmap.bmHeight, + bmp->bitmap.bmPlanes, bmp->bitmap.bmBitsPixel, NULL ))) + { + if (bmp->funcs->pCopyBitmap( bitmap, brush->bitmap )) + { + BITMAPOBJ *copy = GDI_GetObjPtr( brush->bitmap, OBJ_BITMAP ); + copy->funcs = bmp->funcs; + GDI_ReleaseObj( copy ); + } + else + { + DeleteObject( brush->bitmap ); + brush->bitmap = 0; + } + } GDI_ReleaseObj( bitmap ); - brush->bitmap = BITMAP_CopyBitmap( bitmap ); return brush->bitmap != 0; } diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index ab5cf251d7c..3b3022ac1ea 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -229,7 +229,6 @@ extern DWORD stretch_bits( const BITMAPINFO *src_info, struct bitblt_coords *src struct gdi_image_bits *bits, int mode ) DECLSPEC_HIDDEN; /* bitmap.c */ -extern HBITMAP BITMAP_CopyBitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN; extern BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, PHYSDEV physdev ) DECLSPEC_HIDDEN; extern BOOL get_brush_bitmap_info( HBRUSH handle, BITMAPINFO *info, void **bits, UINT *usage ) DECLSPEC_HIDDEN;