[2/3] gdiplus: Use an off-screen DC as an image surface.

Dmitry Timoshkov dmitry at baikal.ru
Wed Feb 20 00:18:13 CST 2013


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

diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 9c34333..59ea41c 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -116,10 +116,9 @@ static INT ipicture_pixel_height(IPicture *pic)
 
     IPicture_get_Height(pic, &y);
 
-    hdcref = GetDC(0);
-
+    hdcref = CreateCompatibleDC(0);
     y = MulDiv(y, GetDeviceCaps(hdcref, LOGPIXELSY), INCH_HIMETRIC);
-    ReleaseDC(0, hdcref);
+    DeleteDC(hdcref);
 
     return y;
 }
@@ -131,11 +130,9 @@ static INT ipicture_pixel_width(IPicture *pic)
 
     IPicture_get_Width(pic, &x);
 
-    hdcref = GetDC(0);
-
+    hdcref = CreateCompatibleDC(0);
     x = MulDiv(x, GetDeviceCaps(hdcref, LOGPIXELSX), INCH_HIMETRIC);
-
-    ReleaseDC(0, hdcref);
+    DeleteDC(hdcref);
 
     return x;
 }
@@ -1688,7 +1685,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap)
     bih.biClrUsed = 0;
     bih.biClrImportant = 0;
 
-    screendc = GetDC(0);
+    screendc = CreateCompatibleDC(0);
     if (iinfo.hbmColor)
     {
         GetDIBits(screendc, iinfo.hbmColor, 0, height, lockeddata.Scan0, (BITMAPINFO*)&bih, DIB_RGB_COLORS);
@@ -1756,7 +1753,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap)
         }
     }
 
-    ReleaseDC(0, screendc);
+    DeleteDC(screendc);
 
     DeleteObject(iinfo.hbmColor);
     DeleteObject(iinfo.hbmMask);
@@ -1806,14 +1803,14 @@ static void generate_halftone_palette(ARGB *entries, UINT count)
 
 static GpStatus get_screen_resolution(REAL *xres, REAL *yres)
 {
-    HDC screendc = GetDC(0);
+    HDC screendc = CreateCompatibleDC(0);
 
     if (!screendc) return GenericError;
 
     *xres = (REAL)GetDeviceCaps(screendc, LOGPIXELSX);
     *yres = (REAL)GetDeviceCaps(screendc, LOGPIXELSY);
 
-    ReleaseDC(0, screendc);
+    DeleteDC(screendc);
 
     return Ok;
 }
-- 
1.8.1.3




More information about the wine-patches mailing list