`
public Bitmap catchFullScreen()
{ Bitmap r = new Bitmap(SystemInformation.VirtualScreen.Width ,SystemInformation.VirtualScreen.Height);
Rectangle bounds = new Rectangle (0,0,SystemInformation.VirtualScreen.Width ,SystemInformation.VirtualScreen.Height);
using (Bitmap bitmap = new Bitmap(SystemInformation.VirtualScreen.Width ,SystemInformation.VirtualScreen.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
r = bitmap;
pictureBox1.Image = r;
pictureBox1.Update();
pictureBox1.Refresh();
}
pictureBox2.Image = r; // breakpoint 1
pictureBox2.Update(); // breakpoint 2
pictureBox2.Refresh();
}
pictureBox3.Image = r;
pictureBox3.Update();
pictureBox3.Refresh();
return r;
}
` Here is my capture screenshot, but something strange is going on, picturebox1 and 2 is able to capture , but picturebox3 does not. further more, breakpoint1 works but breakpoint2 never arrives,
Why cant i use this bitmap after i am outside the using routines?? more important it wont return r? suggestions please!
Bitmap is a class, that is a reference type. When you dispose bitmap
you also dispose your r
. If you want to continue using r
while disposing bitmap
, consider using something like Bitmap.Clone .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.