aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-03-01 12:27:59 +0100
committerSven Gothel <[email protected]>2014-03-01 12:27:59 +0100
commit7a1dbd0d87a15f582f568a20adbbe42505bdca33 (patch)
tree77f6d2679c2828a6ad869a3efd9689c10174e94f /src
parent9aba47241419a7115ebb638e4deb04322ff26d8b (diff)
NEWT MonitorDevice: Add convenient getPixelsPerMM(..) method to retrieve the pixels-per-millimeter (Requires manual Conversion to dpi)
Diffstat (limited to 'src')
-rw-r--r--src/newt/classes/com/jogamp/newt/MonitorDevice.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java
index 28d9f53a1..2d1d912c7 100644
--- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java
+++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java
@@ -33,7 +33,7 @@ import java.util.List;
import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.nativewindow.util.Rectangle;
import javax.media.nativewindow.util.RectangleImmutable;
-
+import javax.media.nativewindow.util.SurfaceSize;
import com.jogamp.common.util.ArrayHashSet;
/**
@@ -119,6 +119,32 @@ public abstract class MonitorDevice {
}
/**
+ * Stores the <i>pixels per millimeter</i> value according to <i>current</i> {@link MonitorMode}
+ * {@link SurfaceSize#getResolution() SurfaceSize's resolution} in the given storage <code>ppmmStore</code>.
+ * <p>
+ * To convert the result to <i>dpi</i>, i.e. dots-per-inch, multiply both components with <code>25.4f</code>.
+ * </p>
+ */
+ public final void getPixelsPerMM(final float[] ppmmStore) {
+ final MonitorMode mode = getCurrentMode();
+ getPixelsPerMM(mode, ppmmStore);
+ }
+
+ /**
+ * Stores the <i>pixels per millimeter</i> value according to the given {@link MonitorMode}
+ * {@link SurfaceSize#getResolution() SurfaceSize's resolution} in the given storage <code>ppmmStore</code>.
+ * <p>
+ * To convert the result to <i>dpi</i>, i.e. dots-per-inch, multiply both components with <code>25.4f</code>.
+ * </p>
+ */
+ public final void getPixelsPerMM(final MonitorMode mode, final float[] ppmmStore) {
+ final DimensionImmutable sdim = getSizeMM();
+ final DimensionImmutable spix = mode.getSurfaceSize().getResolution();
+ ppmmStore[0] = (float)spix.getWidth() / (float)sdim.getWidth();
+ ppmmStore[1] = (float)spix.getHeight() / (float)sdim.getHeight();
+ }
+
+ /**
* Returns the immutable original {@link com.jogamp.newt.MonitorMode}, as used at NEWT initialization.
* <p>
* The returned {@link MonitorMode} is element of the lists {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}.