[07/17] gdiplus: Replace convert_unit() by a clearer units_to_pixels() helper. Part 2.
Dmitry Timoshkov
dmitry at baikal.ru
Wed Aug 8 22:57:26 CDT 2012
---
dlls/gdiplus/image.c | 35 ++++++-----------------------------
1 file changed, 6 insertions(+), 29 deletions(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index f415a45..64ce8b6 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -2256,18 +2256,9 @@ GpStatus WINGDIPAPI GdipGetImageDimension(GpImage *image, REAL *width,
return InvalidParameter;
if(image->type == ImageTypeMetafile){
- HDC hdc = GetDC(0);
- REAL res = (REAL)GetDeviceCaps(hdc, LOGPIXELSX);
-
- ReleaseDC(0, hdc);
-
- *height = convert_unit(res, ((GpMetafile*)image)->unit) *
- ((GpMetafile*)image)->bounds.Height;
-
- *width = convert_unit(res, ((GpMetafile*)image)->unit) *
- ((GpMetafile*)image)->bounds.Width;
+ *height = units_to_pixels(((GpMetafile*)image)->bounds.Height, ((GpMetafile*)image)->unit, image->yres);
+ *width = units_to_pixels(((GpMetafile*)image)->bounds.Width, ((GpMetafile*)image)->unit, image->xres);
}
-
else if(image->type == ImageTypeBitmap){
*height = ((GpBitmap*)image)->height;
*width = ((GpBitmap*)image)->width;
@@ -2326,15 +2317,8 @@ GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
if(!image || !height)
return InvalidParameter;
- if(image->type == ImageTypeMetafile){
- HDC hdc = GetDC(0);
- REAL res = (REAL)GetDeviceCaps(hdc, LOGPIXELSX);
-
- ReleaseDC(0, hdc);
-
- *height = roundr(convert_unit(res, ((GpMetafile*)image)->unit) *
- ((GpMetafile*)image)->bounds.Height);
- }
+ if(image->type == ImageTypeMetafile)
+ *height = units_to_pixels(((GpMetafile*)image)->bounds.Height, ((GpMetafile*)image)->unit, image->yres);
else if(image->type == ImageTypeBitmap)
*height = ((GpBitmap*)image)->height;
else
@@ -2433,15 +2417,8 @@ GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
if(!image || !width)
return InvalidParameter;
- if(image->type == ImageTypeMetafile){
- HDC hdc = GetDC(0);
- REAL res = (REAL)GetDeviceCaps(hdc, LOGPIXELSX);
-
- ReleaseDC(0, hdc);
-
- *width = roundr(convert_unit(res, ((GpMetafile*)image)->unit) *
- ((GpMetafile*)image)->bounds.Width);
- }
+ if(image->type == ImageTypeMetafile)
+ *width = units_to_pixels(((GpMetafile*)image)->bounds.Width, ((GpMetafile*)image)->unit, image->xres);
else if(image->type == ImageTypeBitmap)
*width = ((GpBitmap*)image)->width;
else
--
1.7.11.4
More information about the wine-patches
mailing list