[2/9] gdiplus: replace GetDC(0) with CreateCompatibleDC(0)

Evan Stade estade at gmail.com
Thu Aug 9 20:25:05 CDT 2007


Hi,

I realized it's probably a better idea to create temporary memory DCs
than to use the screen DC.

 dlls/gdiplus/image.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

-- 
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index d779907..a6cf671 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -130,7 +130,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(G
     bmi.bmiHeader.biBitCount = 0;
 
     if(!bm_is_selected){
-        hdc = GetDC(0);
+        hdc = CreateCompatibleDC(0);
         old = SelectObject(hdc, (HBITMAP)hbm);
     }
 
@@ -149,7 +149,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(G
 
     if(!bm_is_selected){
         SelectObject(hdc, old);
-        ReleaseDC(0, hdc);
+        DeleteDC(hdc);
     }
 
     lockeddata->Width = rect->Width;
@@ -210,7 +210,7 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits
     bmi.bmiHeader.biBitCount = 0;
 
     if(!bm_is_selected){
-        hdc = GetDC(0);
+        hdc = CreateCompatibleDC(0);
         old = SelectObject(hdc, (HBITMAP)hbm);
     }
 
@@ -221,7 +221,7 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits
 
     if(!bm_is_selected){
         SelectObject(hdc, old);
-        ReleaseDC(0, hdc);
+        DeleteDC(hdc);
     }
 
     GdipFree(bitmap->bitmapbits);
@@ -677,11 +677,11 @@ GpStatus WINGDIPAPI GdipLoadImageFromStr
 
         if(!hdc){
             HBITMAP old;
-            hdc = GetDC(0);
+            hdc = CreateCompatibleDC(0);
             old = SelectObject(hdc, (HBITMAP)hbm);
             GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, &bmi, DIB_RGB_COLORS);
             SelectObject(hdc, old);
-            ReleaseDC(0, hdc);
+            DeleteDC(hdc);
         }
         else
             GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, &bmi, DIB_RGB_COLORS);
-- 
1.4.1


More information about the wine-patches mailing list