[英]how to release the bmp control that is taken by a graphic object in c#?
i have this code 我有这个代码
Bitmap bmp1, bmp2, bmp3,bmp4;
Graphics gp2,gp3;
if (bmp2 == null)
{
bmp2 = new Bitmap(pictureBox1.Height, pictureBox1.Width);
}
gp2 = Graphics.FromImage(bmp2);
// Rectangle rect = new Rectangle((float)(pictureBox1.Width / 2),(float)(pictureBox1.Height / 2),width, height);
gp2.DrawImageUnscaled(bmp1,0,0);
gp2.FillEllipse(Brushes.Red, (float)(pictureBox1.Width / 2), (float)(pictureBox1.Height / 2), width, height);
gp2.Dispose();
but i am unable to release the control of gp2 as i want to give its control to gp3; 但是我无法释放对gp2的控制,因为我想将其控制权交给gp3;
help required??? 需要帮助吗???
I think you should just be able to dispose of the Graphics
and then call Graphics.FromImage
again. 我认为您应该能够处理
Graphics
,然后再次调用Graphics.FromImage
。 I don't believe disposing of the Graphics
will dispose of the underlying Bitmap
. 我不认为处置
Graphics
将处置基础Bitmap
。 Have you tried it? 你试过了吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.