What is the differ开发者_如何转开发ence between System.Drawing.Point
and System.Drawing.PointF
.
Can you give an example between this two.
Thanks in advance.
Point
uses integer coordinates (int
for X
and Y
).
PointF
uses floating points (float
for X
and Y
).
I think PointF
exists partly because System.Drawing.Graphics
class supports transformation and anti-aliasing. For example, you can draw a line between discrete pixelx in anti-aliasing mode.
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Pen pen = Pens.Red;
// draw two vertical line
e.Graphics.DrawLine(pen, new Point(100, 100), new Point(100, 200));
e.Graphics.DrawLine(pen, new Point(103, 100), new Point(103, 200));
// draw a line exactly in the middle of those two lines
e.Graphics.DrawLine(pen, new PointF(101.5f, 200.0f), new PointF(101.5f, 300.0f)); ;
}
and it will look like
without PointF
those functionalities will be limited.
For Example,In some embedded systems,only support "System.Drawing.Point",you should create "PointF" Type by yourself .
精彩评论