c# 想在picturebox中画bitmap图,因为要处理像素点,又想用 graphics 中的一些工具,代码能这么写吗?
privatevoidbutton1_Click(objectsender,EventArgse)//插入点{bitmap=newBitmap(pictureBox1.W...
private void button1_Click(object sender, EventArgs e)//插入点
{
bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height);
g = Graphics.FromImage((Image)bitmap);
g.CompositingMode = CompositingMode.SourceOver;
g.SmoothingMode = SmoothingMode.None;
g.Clear(Color.White);
Pen p = new Pen(Color.Red, 2);
for (int i = 0; i < 10; i++)
{
g.DrawEllipse(p, data[i].x, data[i].y, 1, 1);
}
pictureBox1.Image = (Image)bitmap;
} 展开
{
bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height);
g = Graphics.FromImage((Image)bitmap);
g.CompositingMode = CompositingMode.SourceOver;
g.SmoothingMode = SmoothingMode.None;
g.Clear(Color.White);
Pen p = new Pen(Color.Red, 2);
for (int i = 0; i < 10; i++)
{
g.DrawEllipse(p, data[i].x, data[i].y, 1, 1);
}
pictureBox1.Image = (Image)bitmap;
} 展开
展开全部
这是何必呢?直接画就好了,连画个圆都这样麻烦,后面其他的怎么办?
Graphics graph = pictureBox1.CreateGraphics();
Rectangle r = new Rectangle(10, 10, 30, 30);
graph.DrawEllipse(Pens.Red, r);
r你可以定义成数组。Rectangles[] r
追问
使用drawDrawEllipse是用来标点,同时还想对每个像素点进行操作,想使用getpixel和setpixel函数,不知道graphics怎么转变成比bitmap进行处理
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询