I was looking on the internet but I didn't find an answer. I need to know in what kind of units drawEllipse works: pixels, centimetres...
I also need to know if there is a easy way to change that units (I need it on centimetres).
Thanks a lot!
I was looking on the internet but I didn't find an answer. I need to know in what kind of units drawEllipse works: pixels, centimetres...
I also need to know if there is a easy way to change that units (I need it on centimetres).
Thanks a lot!
Well, you didn't look too carefully.
DrawEllipse
is a method of the System.Drawing.Graphics
class. Graphics
implements the PageUnit
property which:
Gets or sets the unit of measure used for page coordinates in this Graphics.
The possible values are given by the GraphicsUnit
enumeration.
The default value is measured in Pixel. You can check it by printing this information onto your Form
using the PageUnit property like this:
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawString(e.Graphics.PageUnit.ToString(), new Font("Arial", 14), Brushes.Black, 50, 50);
}
This property can also be used to set the desired unit of measurement like this:
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.PageUnit = GraphicsUnit.Millimeter;
e.Graphics.DrawEllipse(new Pen(Color.Black), 100, 100, 25, 30);
}
Now you should have a black ellipse with a width of 2.5 cm and a height of 3.0 cm at the coordinates of 10 cm in X and 10 cm in Y dimension