Alexandre Julliard : gdi32: Use PutImage directly to set the initial bitmap bits.

Alexandre Julliard julliard at winehq.org
Thu Dec 8 13:43:40 CST 2011


Module: wine
Branch: master
Commit: 910fb482916b8515a59752f64d3153a4811bb9a4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=910fb482916b8515a59752f64d3153a4811bb9a4

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Dec  8 19:58:47 2011 +0100

gdi32: Use PutImage directly to set the initial bitmap bits.

---

 dlls/gdi32/bitmap.c |   37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c
index 4f0b173..510d5f5 100644
--- a/dlls/gdi32/bitmap.c
+++ b/dlls/gdi32/bitmap.c
@@ -513,14 +513,43 @@ LONG WINAPI SetBitmapBits(
 
 static void set_initial_bitmap_bits( HBITMAP hbitmap, BITMAPOBJ *bmp )
 {
-    char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
-    BITMAPINFO *info = (BITMAPINFO *)buffer;
+    char src_bmibuf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
+    BITMAPINFO *src_info = (BITMAPINFO *)src_bmibuf;
+    char dst_bmibuf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
+    BITMAPINFO *dst_info = (BITMAPINFO *)dst_bmibuf;
+    DWORD err;
+    struct gdi_image_bits bits;
+    struct bitblt_coords src, dst;
 
     if (!bmp->bitmap.bmBits) return;
     if (bmp->funcs->pPutImage == nulldrv_PutImage) return;
 
-    get_ddb_bitmapinfo( bmp, info );
-    SetDIBits( 0, hbitmap, 0, bmp->bitmap.bmHeight, bmp->bitmap.bmBits, info, DIB_RGB_COLORS );
+    get_ddb_bitmapinfo( bmp, src_info );
+
+    bits.ptr = bmp->bitmap.bmBits;
+    bits.is_copy = FALSE;
+    bits.free = NULL;
+    bits.param = NULL;
+
+    src.x      = 0;
+    src.y      = 0;
+    src.width  = bmp->bitmap.bmWidth;
+    src.height = bmp->bitmap.bmHeight;
+    src.visrect.left   = 0;
+    src.visrect.top    = 0;
+    src.visrect.right  = bmp->bitmap.bmWidth;
+    src.visrect.bottom = bmp->bitmap.bmHeight;
+    dst = src;
+
+    copy_bitmapinfo( dst_info, src_info );
+
+    err = bmp->funcs->pPutImage( NULL, hbitmap, 0, dst_info, &bits, &src, &dst, 0 );
+    if (err == ERROR_BAD_FORMAT)
+    {
+        err = convert_bits( src_info, &src, dst_info, &bits, FALSE );
+        if (!err) err = bmp->funcs->pPutImage( NULL, hbitmap, 0, dst_info, &bits, &src, &dst, 0 );
+        if (bits.free) bits.free( &bits );
+    }
 }
 
 /***********************************************************************




More information about the wine-cvs mailing list