简体   繁体   中英

Calculate inches and centimeters from pixels in C#

I am working on a Productivity app and need to be able to calculate (in C#) inches and centimeters. Based on pixels, obviously.

When you open Microsoft Word, and search through the Templates, you'll find, for example, business cards. And you'll see that their measurements are based upon inches and/or centimeters. How do they get those calculations when they're dealing only with pixels on a screen?

People generally say "blah blah you can't do that blah blah blah" but that's not true at all. I printed a sample business card, MS Word said it would be about 8"x4". On the screen it was not that big but when it was printed onto paper it was exactly what it said. So it can be done and I don't want to hear another person say "You cannot do that".

I think the conversion of pixels to centimeters depends on the DPI (dots per inch) of the media which is displaying the image.

Also the formula is simple for conversion ie,

points = pixels * 72 / 96

since there 72 points per inch and 96 pixels per inch(you can assume)

You may also check How do you convert pixels into centimeters?

In truth, you don't convert pixels to cm. There is a little more information that is needed and without knowing exactly what it is that you want to do, it is difficult to address this completely. There is a de facto norm of 300 DPI /PPI for printing (that is 300 / 2.54 pixels/cm).

A pixel is one of the colored dots on your computer screen that makes up both images and text (as well as all of the blank areas in between them). Most computer screens display either 72 or 96 pixels per inch. Most printing is based on 300 pixels per inch (rarely 240 PPI).

If you are asking about printing: If you want to make a 4 x 6 inch print on a 300 DPI (Dot Per Inch) printer you need your file to contain 1200 x 1800 pixels. An 8 x10 printout will have to be 2400 x 3000 pixels. In reality, most consumer printing systems will handle this conversion for you. You just tell the software what size print you want to make the software will "re size" your image to the correct dimensions.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM