开发者

how to release the bmp control that is taken by a graphic object in c#?

开发者 https://www.devze.com 2023-01-05 20:47 出处:网络
i have this code Bitmap bmp1, bmp2, bmp3,bmp4; Graphics gp2,gp3; if (bmp2 == null) { 开发者_如何学JAVAbmp2 = new Bitmap(pictureBox1.Height, pictureBox1.Width);

i have this code

Bitmap bmp1, bmp2, bmp3,bmp4;

        Graphics gp2,gp3;



if (bmp2 == null)
                {
      开发者_如何学JAVA              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;

help required???


I think you should just be able to dispose of the Graphics and then call Graphics.FromImage again. I don't believe disposing of the Graphics will dispose of the underlying Bitmap. Have you tried it?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号