My problem is that what I size a picture according to millimeters to pixels, and then print it out this will never be exact. My question is there a way to make java draw in millimeters or any other metric unit stead of pixels, because pixils will never be exact to millimeters.
Get the screen DPI
using java.awt.Toolkit.getDefaultToolkit().getScreenResolution();
Then simply do (MM * DPI)/25.4
.
The outcome will be the amount of pixels relative to the physical length in MM.
If you know the resolution - px/cm you can do the calculation in centimeters I guess. However, printers and displays have different resolutions based on the hardware itself. In Photoshop for example you can define how many pixels per inch you desire. Whether a printer can actually print the defined density depends on the printer itself.
As an extreme example think about a 46 inch television and your smart phone. Both claim 1080 hd images but clearly the size in inches is drastically different.
Doing some analysis, you could understand better:
pixels = mm * inch/mm * pixels/inch
pixels = mm (milimeters) * 25.4 (how many inches I have in 1 mm) * DPI (screen resolution)
DPI is dots per inch, which is the same of pixels per inch.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.