Avoid using deprecated GLControl.GrabScreenshot() method.

This commit is contained in:
the_fiddler 2010-10-22 15:04:04 +00:00
parent 23b2cd74fd
commit eb04d4996c

View file

@ -66,7 +66,9 @@ namespace Examples.WinForms
void glControl_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F12)
glControl.GrabScreenshot().Save("screenshot.png");
{
GrabScreenshot().Save("screenshot.png");
}
}
#endregion
@ -204,6 +206,23 @@ namespace Examples.WinForms
#endregion
#region private void GrabScreenshot()
Bitmap GrabScreenshot()
{
Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
System.Drawing.Imaging.BitmapData data =
bmp.LockBits(this.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
GL.ReadPixels(0, 0, this.ClientSize.Width, this.ClientSize.Height, PixelFormat.Bgr, PixelType.UnsignedByte,
data.Scan0);
bmp.UnlockBits(data);
bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
return bmp;
}
#endregion
#region public static void Main()
/// <summary>