Alexandre Julliard : gdi32: Use the CopyBitmap entry point to copy the bitmap of a pattern brush.
Alexandre Julliard
julliard at winehq.org
Wed Nov 9 13:29:41 CST 2011
Module: wine
Branch: master
Commit: 0c5d619bd38554d406b11973cdd5653192137025
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0c5d619bd38554d406b11973cdd5653192137025
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Nov 7 22:06:57 2011 +0100
gdi32: Use the CopyBitmap entry point to copy the bitmap of a pattern brush.
---
dlls/gdi32/bitmap.c | 53 ----------------------------------------------
dlls/gdi32/brush.c | 16 +++++++++++++-
dlls/gdi32/gdi_private.h | 1 -
3 files changed, 15 insertions(+), 55 deletions(-)
diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c
index 9042b88..282e22b 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 ccd1369..579e9fd 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 ab5cf25..3b3022a 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;
More information about the wine-cvs
mailing list