[3/6] gdiplus: return width and height for metafiles

Evan Stade estade at gmail.com
Mon Aug 6 20:55:45 CDT 2007


Hi,

changelog:
*moved helper to gdiplus.c, declared it in gdiplus_private
*return width and height for metafiles

 dlls/gdiplus/gdiplus.c         |   23 +++++++++++++++++++++++
 dlls/gdiplus/gdiplus_private.h |    1 +
 dlls/gdiplus/graphics.c        |   22 ----------------------
 dlls/gdiplus/image.c           |   16 ++++++++++++----
 4 files changed, 36 insertions(+), 26 deletions(-)

-- 
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/gdiplus.c b/dlls/gdiplus/gdiplus.c
index 3787836..8000471 100644
--- a/dlls/gdiplus/gdiplus.c
+++ b/dlls/gdiplus/gdiplus.c
@@ -246,3 +246,26 @@ REAL gdiplus_atan2(REAL dy, REAL dx)
 
     return atan2(dy, dx);
 }
+
+/* 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 79440a2..90ff38c 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -41,6 +41,7 @@ COLORREF ARGB2COLORREF(ARGB color);
 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 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 c21e891..3615157 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -79,28 +79,6 @@ static BYTE convert_path_point_type(BYTE
     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 f71f26f..0f5c7da 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -445,8 +445,12 @@ GpStatus WINGDIPAPI GdipGetImageHeight(G
         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;
@@ -527,8 +531,12 @@ GpStatus WINGDIPAPI GdipGetImageWidth(Gp
         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;
-- 
1.4.1


More information about the wine-patches mailing list