开发者

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)
                {
      开发者_如何学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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜