diff win/dw.c @ 1684:31dd366acfc8

Fixed calculating the GDI+ ratio based on the DPI on Windows. Not sure if I am getting to the result correctly but it is working. Also explicitly turn off anti-aliasing when drawing rectangles in the test program, so the edges don't look odd.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 30 Apr 2012 11:54:19 +0000
parents 19c34a1c1489
children 31f16da1052a
line wrap: on
line diff
--- a/win/dw.c	Mon Apr 30 07:13:14 2012 +0000
+++ b/win/dw.c	Mon Apr 30 11:54:19 2012 +0000
@@ -10108,17 +10108,20 @@
  */
 void _convert_dpi(HDC hdc, int *x, int *y, int mult)
 {
-   float ratiox = (float)GetDeviceCaps(hdc, LOGPIXELSX)/96.0;
-   float ratioy = (float)GetDeviceCaps(hdc, LOGPIXELSY)/96.0;
-   if(mult)
-   {
-      *x *= ratiox;
-      *y *= ratioy;
-   }
-   else
-   {
-      *x /= ratiox;
-      *y /= ratioy;
+   int ratiox = (int)GetDeviceCaps(hdc, LOGPIXELSX)/96;
+   int ratioy = (int)GetDeviceCaps(hdc, LOGPIXELSY)/96;
+   if(ratiox > 1 && ratioy > 1)
+   {
+      if(mult)
+      {
+         *x *= ratiox;
+         *y *= ratioy;
+      }
+      else
+      {
+         *x /= ratiox;
+         *y /= ratioy;
+      }
    }
 }
 #endif