[2/4] gdiplus: Use one GetDIBits call instead of one per row.

Vincent Povirk madewokherd at gmail.com
Wed Dec 5 14:18:37 CST 2012


-------------- next part --------------
From eb3de399d2fcbf13373d00da888af9716b4e8d1e Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Wed, 5 Dec 2012 10:42:49 -0600
Subject: [PATCH 2/4] gdiplus: Use one GetDIBits call instead of one per row.

---
 dlls/gdiplus/image.c |   22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index a8f43e3..70c868d 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -4645,7 +4645,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
     GpStatus retval;
     PixelFormat format;
     BitmapData lockeddata;
-    INT y;
 
     TRACE("%p %p %p\n", hbm, hpal, bitmap);
 
@@ -4697,8 +4696,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
             HDC hdc;
             HBITMAP oldhbm;
             BITMAPINFO *pbmi;
-            INT src_height, dst_stride;
-            BYTE *dst_bits;
+            INT src_height;
 
             hdc = CreateCompatibleDC(NULL);
             oldhbm = SelectObject(hdc, hbm);
@@ -4713,23 +4711,9 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
                 GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
 
                 src_height = abs(pbmi->bmiHeader.biHeight);
+                pbmi->bmiHeader.biHeight = -src_height;
 
-                if (pbmi->bmiHeader.biHeight > 0)
-                {
-                    dst_bits = (BYTE*)lockeddata.Scan0+lockeddata.Stride*(src_height-1);
-                    dst_stride = -lockeddata.Stride;
-                }
-                else
-                {
-                    dst_bits = lockeddata.Scan0;
-                    dst_stride = lockeddata.Stride;
-                }
-
-                for (y=0; y<src_height; y++)
-                {
-                    GetDIBits(hdc, hbm, y, 1, dst_bits+dst_stride*y,
-                        pbmi, DIB_RGB_COLORS);
-                }
+                GetDIBits(hdc, hbm, 0, src_height, lockeddata.Scan0, pbmi, DIB_RGB_COLORS);
 
                 GdipFree(pbmi);
             }
-- 
1.7.10.4


More information about the wine-patches mailing list