From eb04d4996c768f9b8477287eef3c9c52cc738e48 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Fri, 22 Oct 2010 15:04:04 +0000 Subject: [PATCH] Avoid using deprecated GLControl.GrabScreenshot() method. --- .../OpenTK/GLControl/GLControlGameLoop.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Source/Examples/OpenTK/GLControl/GLControlGameLoop.cs b/Source/Examples/OpenTK/GLControl/GLControlGameLoop.cs index 816fb039..66b5bff5 100644 --- a/Source/Examples/OpenTK/GLControl/GLControlGameLoop.cs +++ b/Source/Examples/OpenTK/GLControl/GLControlGameLoop.cs @@ -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() ///