System.Drawing.Point 和 System.Drawing.PointF 有什么区别

发布于 2024-09-24 00:34:38 字数 118 浏览 1 评论 0原文

System.Drawing.PointSystem.Drawing.PointF 之间有什么区别。 你能举一个介于这两者之间的例子吗?

提前致谢。

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

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

挖个坑埋了你 2024-10-01 00:34:38

Point 使用整数坐标(XYint)。

PointF 使用浮点(float 表示 XY)。

Point uses integer coordinates (int for X and Y).

PointF uses floating points (float for X and Y).

风轻花落早 2024-10-01 00:34:38

我认为 PointF 存在的部分原因是 System.Drawing.Graphics 类支持转换和抗锯齿。例如,您可以在抗锯齿模式下在离散像素之间画一条线。

    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)); ;
    }

看起来像

this

没有 PointF 这些功能将受到限制。

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

this

without PointF those functionalities will be limited.

流绪微梦 2024-10-01 00:34:38

例如,在某些嵌入式系统中,仅支持“System.Drawing.Point”,您应该自己创建“PointF”类型。

For Example,In some embedded systems,only support "System.Drawing.Point",you should create "PointF" Type by yourself .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文