Re: how to convert metric to pixels



Rita Leon wrote:
What are the methods/classes in JFC to convert millimeters (or inches
or centimeters) to pixels?

I remember in windows programming we had DPtoLP() and LPtoDP(). Might
there be a Java equivalent?
You can call
int resolution = Toolkit.getDefaultToolkit().getScreenResolution();
to get your physical screen resolution (on my screen I get 96). Having that number, it is simple arithmetics to convert inches to pixels and vice versa.

See <http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Toolkit.html#getScreenResolution()>

--
Thomas
.



Relevant Pages

  • Re: how to convert metric to pixels
    ... You idea is possible but the number of pixels per unit will vary ... depending on the physical size of the monitor and the size of a pixel. ... getScreenResolution, you would have seen that the value that is returned ... to get your physical screen resolution. ...
    (comp.lang.java.help)
  • Re: how to convert metric to pixels
    ... You idea is possible but the number of pixels per unit will vary ... depending on the physical size of the monitor and the size of a pixel. ... to get your physical screen resolution. ...
    (comp.lang.java.help)