diff --git a/dlls/gdiplus/gdiplus.c b/dlls/gdiplus/gdiplus.c index 998cec85ea3..e8499c6897b 100644 --- a/dlls/gdiplus/gdiplus.c +++ b/dlls/gdiplus/gdiplus.c @@ -263,3 +263,26 @@ GpStatus hresult_to_status(HRESULT res) return GenericError; } } + +/* converts a given unit to its value in pixels */ +REAL convert_unit(HDC hdc, GpUnit unit) +{ + switch(unit) + { + case UnitInch: + return (REAL) GetDeviceCaps(hdc, LOGPIXELSX); + case UnitPoint: + return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 72.0; + case UnitDocument: + return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 300.0; + case UnitMillimeter: + return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 25.4; + case UnitWorld: + ERR("cannot convert UnitWorld\n"); + return 0.0; + case UnitPixel: + case UnitDisplay: + default: + return 1.0; + } +} diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 130703ddce3..7f56ea70c12 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -42,6 +42,7 @@ extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2, REAL startAngle, REAL sweepAngle); extern REAL gdiplus_atan2(REAL dy, REAL dx); extern GpStatus hresult_to_status(HRESULT res); +extern REAL convert_unit(HDC hdc, GpUnit unit); static inline INT roundr(REAL x) { diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 978723472ec..57ad025d880 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -82,28 +82,6 @@ static BYTE convert_path_point_type(BYTE type) return ret; } -static REAL convert_unit(HDC hdc, GpUnit unit) -{ - switch(unit) - { - case UnitInch: - return (REAL) GetDeviceCaps(hdc, LOGPIXELSX); - case UnitPoint: - return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 72.0; - case UnitDocument: - return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 300.0; - case UnitMillimeter: - return ((REAL)GetDeviceCaps(hdc, LOGPIXELSX)) / 25.4; - case UnitWorld: - ERR("cannot convert UnitWorld\n"); - return 0.0; - case UnitPixel: - case UnitDisplay: - default: - return 1.0; - } -} - static INT prepare_dc(GpGraphics *graphics, GpPen *pen) { HPEN gdipen; diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index da816b85a7b..d6723270bb4 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -417,8 +417,12 @@ GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height) return InvalidParameter; if(image->type == ImageTypeMetafile){ - FIXME("not implemented for metafiles\n"); - return NotImplemented; + HDC hdc = GetDC(0); + + *height = roundr(convert_unit(hdc, ((GpMetafile*)image)->unit) * + ((GpMetafile*)image)->bounds.Height); + + ReleaseDC(0, hdc); } else if(image->type == ImageTypeBitmap) *height = ((GpBitmap*)image)->height; @@ -499,8 +503,12 @@ GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width) return InvalidParameter; if(image->type == ImageTypeMetafile){ - FIXME("not implemented for metafiles\n"); - return NotImplemented; + HDC hdc = GetDC(0); + + *width = roundr(convert_unit(hdc, ((GpMetafile*)image)->unit) * + ((GpMetafile*)image)->bounds.Width); + + ReleaseDC(0, hdc); } else if(image->type == ImageTypeBitmap) *width = ((GpBitmap*)image)->width;