dcsimg
How to translate from metrics to pixels?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Joar_Vatnaland
Posted On:   Friday, February 8, 2002 01:52 AM

I want to create an image from a byte-array with MemoryImageSource. The constructor of this class wants to know the dimensions of the picture in pixels. I only know the dimensions in micrometers ( 1/1000 of millimeters ). Is there any way that I can convert that to pixels?

Re: How to translate from metrics to pixels?

Posted By:   Danilo_Cividin  
Posted On:   Tuesday, February 12, 2002 03:39 AM

For first instance, sorry for my bad english.

To convert pixel to metrics and metrics to pixel, you must know two thinks :



1 - an inches = 2.54 cm

2 - inches resolution, is depend of the support.

In the Screen on PC the resolution is 72pixel/inches.

In a printer can be 300 dot/inches



To convert cm to pixel :



pixel = (cm * resolution)/inches

es



20cm * 72(screen res)

--------------------- = ~566 pixel

2.54





To convert pixel to cm:



cm = (pixel * inches)/resolution



es



1024 pix * 2.54

--------------------- = 8,67cm

300 (printer resolution)

Re: How to translate from metrics to pixels?

Posted By:   Christopher_Schultz  
Posted On:   Friday, February 8, 2002 05:18 AM

This is a hard one. I poked around in the GraphicsDevice class and friends in the JavaDoc, confident that these would hold the answer, but I found nothing.



Sorry, I'm out of ideas. I'd be interested to learn how you solve this problem, though.



Good luck,

-chris
About | Sitemap | Contact