From 0553eba08f15a321838f34e7aac15ead64c2cb03 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Wed, 20 Feb 2013 14:18:13 +0800 Subject: [PATCH] gdiplus: Use an off-screen DC as an image surface. --- 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 9c3433309a5..59ea41c08a1 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; }