Print OpenGLControl from C#

Hey! I'd like to print the drawing I have on an OpenGL Control using C#, is there any function or does any one have any code that might help?? I'd really appreciate it!!

Use Gl.glReadPixels to read

Use Gl.glReadPixels to read the contents of the screen into a byte array, create a System.Drawing.Bitmap and print that. Smiling

------
OpenTK

Thank you very much

Thank you very much StApostol! I'll try to figure it out with that Procedure!! Thank you!

#region public


#region public Bitmap GrabScreenshot()

/// Grabs a screenshot of the frontbuffer contents.
/// A System.Drawing.Bitmap, containing the contents of the frontbuffer.
public 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.glReadPixels(0, 0, this.ClientSize.Width, this.ClientSize.Height, Gl.GL_BGR, PixelType.UnsignedByte,
data.Scan0);
bmp.UnlockBits(data);
bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
return bmp;
}

#endregion

Source

Theme by La Boite a site | Powered by Drupal