CSGL Save OpenGL Frame as picture

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MIrchhh
    New Member
    • May 2013
    • 1

    CSGL Save OpenGL Frame as picture

    Hello,

    I saw a problem about that. And I tried below code to do it. But all of informations are gotten as 0. I could not save frame as Picture. Could you help me? I use C# CSGL.

    Code:
    public void saveScene()
    {
    Size s = Size;
    
    Bitmap b = new Bitmap(s.Width, s.Height,
    PixelFormat.Format32bppArgb);
    BitmapData bd = b.LockBits(new Rectangle(0, 0, s.Width, s.Height),
    ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
    GL.glReadPixels(0, 0, s.Width, s.Height, GL.GL_BGRA_EXT,
    GL.GL_UNSIGNED_BYTE, bd.Scan0);
    b.UnlockBits(bd);
    //b.RotateFlip();
    b.Save(@"c:\test.bmp", ImageFormat.Bmp);
    }
Working...