相关文章推荐
踏实的胡萝卜  ·  Sql ...·  2 年前    · 
坏坏的小狗  ·  visual c++ - C26495 ...·  3 年前    · 
冲动的野马  ·  C# ...·  3 年前    · 
酷酷的牙膏  ·  使用RailWay部署Halo ...·  3 年前    · 
果断的土豆  ·  gorm ...·  3 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

What is the difference between System.Drawing.Point and System.Drawing.PointF . Can you give an example between this two.

Thanks in advance.

Check msdn for Point and PointF and especially compare the datatype of the X and Y properties. – Hans Kesting Sep 17, 2010 at 8:30 Why the downvote? The question sounded like something the OP could figure out himself, at least the "difference" part. – Hans Kesting Sep 17, 2010 at 8:49 In almost all the methods on System.Drawing.Graphics . For example, Graphics.DrawLine can take either Point or PointF parameters. – Timwi Sep 17, 2010 at 8:39 @Timwi thanks, so PointF cannot be use on user control properties? for example Location ? – Rye Sep 17, 2010 at 8:49 @Rye: I believe most of Windows Forms uses an integer coordinate system, whereas most of WPF uses a double -based coordinate system. – Jon Skeet Sep 17, 2010 at 9:01

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.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid …

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.