EMF: Fix the bounding box calculation

Michael Kaufmann hallo at michael-kaufmann.ch
Tue Jan 24 14:13:42 CST 2006


Changelog:
- Enhanced Metafiles: Properly calculate the bounding box for mappings 
with opposite window/viewport axes
-------------- next part --------------
Index: dlls/gdi/enhmfdrv/init.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/enhmfdrv/init.c,v
retrieving revision 1.33
diff -u -r1.33 init.c
--- dlls/gdi/enhmfdrv/init.c	31 Oct 2005 10:05:53 -0000	1.33
+++ dlls/gdi/enhmfdrv/init.c	22 Jan 2006 15:39:50 -0000
@@ -225,16 +225,34 @@
     RECTL vportRect = *rect;
 
     LPtoDP(physDev->hdc, (LPPOINT)&vportRect, 2);
+    
+    /* The coordinate systems may be mirrored
+       (LPtoDP handles points, not rectangles) */
+    if (vportRect.left > vportRect.right)
+    {
+        LONG temp = vportRect.right;
+        vportRect.right = vportRect.left;
+        vportRect.left = temp;
+    }
+    if (vportRect.top > vportRect.bottom)
+    {
+        LONG temp = vportRect.bottom;
+        vportRect.bottom = vportRect.top;
+        vportRect.top = temp;
+    }
 
-    if(bounds->left > bounds->right) {/* first rect */
-	*bounds = vportRect;
-	return;
-    }
-    bounds->left   = min(bounds->left,   vportRect.left);
-    bounds->top    = min(bounds->top,    vportRect.top);
-    bounds->right  = max(bounds->right,  vportRect.right);
-    bounds->bottom = max(bounds->bottom, vportRect.bottom);
-    return;
+    if (bounds->left > bounds->right)
+    {
+        /* first bounding rectangle */
+        *bounds = vportRect;
+    }
+    else
+    {
+        bounds->left   = min(bounds->left,   vportRect.left);
+        bounds->top    = min(bounds->top,    vportRect.top);
+        bounds->right  = max(bounds->right,  vportRect.right);
+        bounds->bottom = max(bounds->bottom, vportRect.bottom);
+    }
 }
 
 /**********************************************************************


More information about the wine-patches mailing list