如何在PictureBox图像上绘制图像

我需要知道如何在PictureBox的图像上绘制多个图像。

我使用过这段代码,但它不起作用:

private void button3_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(pictureBox2.Image); Graphics g = Graphics.FromImage(bmp); g.DrawImage(new Bitmap(@"C:\Users\Mena\Desktop\1.png"), new Point(182, 213)); pictureBox2.Image = bmp; } 

通过一些更改,您的代码将正常工作:

 private void button3_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(pictureBox2.Image); // whatever your plans where, we don't know ;-) // RectangleF rectf = new RectangleF(640F, 1100F, 0, 0); Graphics g = Graphics.FromImage(bmp); // DrawImage needs an image, not a string g.DrawImage(new Bitmap(@"C:\Users\Mena\Desktop\1.png"), new Point(182, 213)); // flush is for finishing write operations // dispose is the command to get rid of GDI elements: g.Dispose(); pictureBox2.Image = bmp; } 

建议的方法是:

 private void button3_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(pictureBox2.Image); using (Graphics g = Graphics.FromImage(bmp)) { g.DrawImage(new Bitmap((@"C:\Users\Mena\Desktop\1.png"), new Point(182, 213)); } pictureBox2.Image = bmp; }