gdiplus: Use an off-screen DC as an image surface.

This commit is contained in:
Dmitry Timoshkov 2013-02-20 14:18:13 +08:00 committed by Alexandre Julliard
parent 97b92fe12c
commit 0553eba08f
1 changed files with 8 additions and 11 deletions

View File

@ -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;
}