< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp

Print this page

        

@@ -35,10 +35,12 @@
 #include <shellapi.h>
 #include <shlobj.h>
 
 #include "math.h"
 
+#define ROUND_TO_INT(num)    ((int) floor((num) + 0.5))
+
 // WDesktopProperties fields
 jfieldID AwtDesktopProperties::pDataID = 0;
 jmethodID AwtDesktopProperties::setBooleanPropertyID = 0;
 jmethodID AwtDesktopProperties::setIntegerPropertyID = 0;
 jmethodID AwtDesktopProperties::setStringPropertyID = 0;

@@ -90,11 +92,11 @@
     invScaleX = (dpiX == 0.0f) ? 1.0f : 96.0f / dpiX;
     invScaleY = (dpiY == 0.0f) ? 1.0f : 96.0f / dpiY;
 }
 
 int rescale(int value, float invScale){
-    return invScale == 1.0f ? value : (int)round(value * invScale);
+    return invScale == 1.0f ? value : ROUND_TO_INT(value * invScale);
 }
 
 void AwtDesktopProperties::GetSystemProperties() {
     HDC dc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
 
< prev index next >