Pixel to Centimeter?

2019-01-07 09:41发布

问题:

I just want to know if the pixel unit is something that doesn't change, and if we can convert from pixels to let's say centimeters ?

回答1:

Similar to this question which asks about points instead of centimeters. There are 72 points per inch and there are 2.54 centimeters per inch, so just substitute 2.54 for 72 in the answer to that question. I'll quote and correct my answer here:

There are 2.54 centimeters per inch; if it is sufficient to assume 96 pixels per inch, the formula is rather simple:

centimeters = pixels * 2.54 / 96

There is a way to get the configured pixels per inch of your display for Microsoft Windows called GetDeviceCaps. Microsoft has a guide called "Developing DPI-Aware Applications", look for the section "Creating DPI-Aware Fonts".



回答2:

Converting pixels to centimeters depends on the DPI (dots per inch) of the media displaying the image, i.e. monitor, laser printer, etc.

http://wiki.answers.com/Q/How_do_you_convert_pixels_into_centimeters



回答3:

I'm going to go out on a limb and just guess that you want to be able to display things to the user on their monitor, scaled to be very close to its real life size.

IF this is the case, I would recommend either displaying your items next to real life items (credit cards, dollar bills, pop cans, etc) or even better, allow the user to hold something up to the screen like a credit card or dollar bill or ruler. You could then have them scale a slider or something similar to meet the width or height of that object.

By holding a credit card, something with a relatively known height and width, up to the screen, you can easily determine the ratio of pixels to inches and use that to your hearts content.

Wiki says

Most credit cards are issued by local banks or credit unions, and are the shape and size specified by the ISO/IEC 7810 standard as ID-1 (85.60 × 53.98 mm)

Using mspaint, a credit card of mine is exactly 212 pixels tall, thats 53.98mm / 212 pixels = 3.92 pixels per mm. Multiply by 10 and that's 39.2 pixels per cm.

You could EASILY do that programatically via javascript, C#, flash, whatever you want.



回答4:

You can convert from pixels to centimeters, but it's not a consistent conversion. It will depend on the size and resolution of the display device in question. The definition of a pixel will not change, but the size of a pixel will vary on different display devices.



回答5:

No, different mediums & monitors have different pixel density.

For instance a desktop monitor may have 75 pixels per inch whereas a print may be outputted at 300.

Here is a list of displays by pixel density



回答6:

In Adobe Illustrator CS3 :(, the figure I get is 1 cm = 28.347 pixels. Note I am using an iMac 7. that has a resolution of 102 pixels per inch, 40 ppcm according to the link http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density provided by rebo.

I created an Adobe Illustrator CS3 document using javascript to test the value of 1 cm = 28.347 pixels and it matches perfectly.

I know this question is very old but I was trying to find an answer to it and decided to share my findings.

Regards



回答7:

The size of pixels change depending on the display device.

The following "found" code uses api calls to determine pixel density Get screen DPI in .NET

("Found" as in I googled it but haven't tried it)



回答8:

As far as I understand it, a PIXEL is:

Picture Element

thus it depends on two things:

(a) Resolution (b) Physical Screen size

Thus if you divide screen size by resolution, this should give you CM per Pixel.



回答9:

The pixel system is that it depend on your screen resolution. Well , first you should get the dpi(density pixel perInch) of your screen. For example your screen dpi is 96;

1 CM = 37.795276F Pixel in 96dpi.

37.795276F / 96F = 0.03937007F which is each pixel in 1dpi.

now you can make it adapted to your screen by getting the current dpi of screen and multiply it to 0.03937007F. then you have each Centimeter in your desire dpi(screen resolution)

lets set scenario .

I want to make a methode which get CM and return pixel base on screen Dpi;

public float CentimeterToPixel(int valueCM, float dpi)
{
   return 0.03937007F * dpi * valueCM;
}

if you want to make it more accurate you have to approach dpiX & dpiY.

for example in C# winforms You can add an object of Graphics from System.Drawing And System.Drawing.Drawing2D then Get it dpiX & dpiY value and design youre area based on it to have more acurate calculation(in some case that horizontal resolution differ from vertical). See the code bellow.

using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace MyApp
{
    static class MyAppClass
    {
        private static Bitmap bmp = new Bitmap(1, 1);// a simple bitmap that automaticaly created base on current screen resolution
        private static Graphics graphic = Graphics.FromImage(bmp);

        public static float CentimeterToPixelWidth(int valueCM)
        {
           return 0.03937007F * graphic.DpiX * valueCM;
        }

        public static float CentimeterToPixelHeight(int valueCM)
        {
           return 0.03937007F * graphic.DpiY * valueCM;
        }
    }

}

Whish it help you, Heydar.