[PATCH] (try 2) gdiplus: Fix errors in image dimensions.

Nathan Beckmann nathan.beckmann at gmail.com
Thu Mar 6 02:28:04 CST 2008


Use more precise calculations in GdipGetImageDimension.

Add rounding to GdipLoadImageFromStream to account for errors in unit
conversion.

This is in response to a bug found while doing tests for
GdipSaveImageToFile (patch forthcoming). Also fixes Bug 11778.

(try 2): Used MulDiv, as suggested by Dmitry Timoshkov. Also kept the
old way of computing dimensions in GetImageDimension, as extra digits
are due to computational error.
---
 dlls/gdiplus/image.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 330d90f..de5c1aa 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -45,8 +45,7 @@ static INT ipicture_pixel_height(IPicture *pic)
 
     hdcref = GetDC(0);
 
-    y = (UINT)(((REAL)y) * ((REAL)GetDeviceCaps(hdcref, LOGPIXELSY)) /
-              ((REAL)INCH_HIMETRIC));
+    y = MulDiv(y, GetDeviceCaps(hdcref, LOGPIXELSY), INCH_HIMETRIC);
     ReleaseDC(0, hdcref);
 
     return y;
@@ -61,8 +60,7 @@ static INT ipicture_pixel_width(IPicture *pic)
 
     hdcref = GetDC(0);
 
-    x = (UINT)(((REAL)x) * ((REAL)GetDeviceCaps(hdcref, LOGPIXELSX)) /
-              ((REAL)INCH_HIMETRIC));
+    x = MulDiv(x, GetDeviceCaps(hdcref, LOGPIXELSX), INCH_HIMETRIC);
 
     ReleaseDC(0, hdcref);
 
-- 
1.5.4.2




More information about the wine-patches mailing list