< prev index next >

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

Print this page

        

@@ -35,10 +35,16 @@
 #include <shellapi.h>
 #include <shlobj.h>
 
 #include "math.h"
 
+#if defined(_MSC_VER) && _MSC_VER >= 1800
+#  define ROUND_TO_INT(num)    ((int) round(num))
+#else
+#  define ROUND_TO_INT(num)    ((int) floor((num) + 0.5))
+#endif
+
 // WDesktopProperties fields
 jfieldID AwtDesktopProperties::pDataID = 0;
 jmethodID AwtDesktopProperties::setBooleanPropertyID = 0;
 jmethodID AwtDesktopProperties::setIntegerPropertyID = 0;
 jmethodID AwtDesktopProperties::setStringPropertyID = 0;

@@ -90,11 +96,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 >