如何按像素添加路径? [英] How to add path by pixels?

查看:132
本文介绍了如何按像素添加路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:

I have:

GraphicsPath path = new GraphicsPath();



我想按像素添加路径,而不是逐点。



Point Class不匹配,因为它增加了最小2像素而不是一个。


I wanna add a path by pixels, not by point.

Point Class doesn't match, because it adds minimum 2 pixels, not one.

private void Draw(object sender, System.Windows.Forms.PaintEventArgs e)
{
    e.Graphics.DrawLine(Pens.Red, 10, 10, 10, 10); // Adds nothing.
    e.Graphics.DrawLine(Pens.Red, 10, 10, 11, 10); // Adds 2 pixels.
}

推荐答案

Graphics类没有SetPixel方法。



我认为你需要研究 Bitmap.SetPixel方法 [ ^ ]



或者您可以通过平台调用使用GDI函数。

C#GetPixel和SetPixel [ ^ ]



这取决于您的其他要求适合您。
The Graphics class doesn't have a SetPixel method.

I think you need to look into Bitmap.SetPixel Method[^]

Or you can use GDI functions via Platform Invoke.
C# GetPixel and SetPixel[^]

It depends on your other requirements what is suitable for you.


这篇关于如何按像素添加路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆