I'm working with a printdocument in which position I assign it with PointF variables, but I want to know how many units of this type of varibles are equivalent to one centimeter.
I'm working with a printdocument in which position I assign it with PointF variables, but I want to know how many units of this type of varibles are equivalent to one centimeter.
Let's see how I can explain it to you, this is not a rule that applies to everything. PointF is a structure that has 2 properties X and Y of type double, these two properties mark a PIXEL, exact of the screen.
For what you ask, you would have, first if you want to measure one centimeter up / down (Y) or to Left / Right (X).
The conversion is more complicated pq depends on the definition and screen of each user, usually the screens usually have 96 dpi, which are pixels per inch. To this you have to add that 1 inch is 2.54 cm, and you only have to make the rule of 3 and you already have it.
1 cm = 1 / 2.54 = 0.393701 inches 1 inch has 96 pixels. 1 cm has 96 * 0.393701 = 37.795296 pixels
And in code, something like this:
public double CmAPixels(int cm)
{
return 96 * 0.393701 * cm;
}
public void Main()
{
PointF.X = CmAPixels(10);
}
Remember that it always depends on the user's resolution and screen.