示例#1
0
 public Bitmap GrabScreenshot(GLForm frm)
 {
     if (GraphicsContext.CurrentContext == null)
         throw new GraphicsContextMissingException();
     int Width = frm.glControl1.ClientSize.Width;
     int Height = frm.glControl1.ClientSize.Height;
     Bitmap bmp = new Bitmap(frm.glControl1.ClientSize.Width, Height);
     System.Drawing.Imaging.BitmapData data =
         bmp.LockBits(new Rectangle(0, 0, Width, Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
     GL.ReadPixels(0, 0, Width, Height, OpenTK.Graphics.PixelFormat.Bgr, PixelType.UnsignedByte, data.Scan0);
     bmp.UnlockBits(data);
     bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
     return bmp;
 }