Avoid using deprecated GLControl.GrabScreenshot() method.
This commit is contained in:
parent
23b2cd74fd
commit
eb04d4996c
1 changed files with 20 additions and 1 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue