Hello everyone,
I have 2 codes (I found in here/internet) that suppost to copy the pixels from my screen (By the OpenGL lib) into a Bitmap class.
The problem is that both of them print a black screen.
The codes:
static Bitmap GrabScreenshot()
{
Bitmap bmp = new Bitmap(800, 600);
System.Drawing.Imaging.BitmapData data = bmp.LockBits(new Rectangle(0, 0, 800, 600), System.Drawing.Imaging.ImageLockMode.WriteOnly,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
GL.glReadPixels(0, 0, 800, 600, GL.GL_BGR, GL.GL_UNSIGNED_BYTE, data.Scan0);
GL.glFinish();
bmp.UnlockBits(data);
bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
return bmp;
}
static Bitmap GrabScreenshot()
{
Size s = new Size();
s.Width = 800;
s.Height = 600;
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(RotateFlipType.Rotate180FlipX);
return b
My main idea is to capture a screen when you are in a 3D game (Like: Counter-Strike/Counter-Strike:Source),
and few people told me that the solution for it is using OpenGL,
Thanks in advanced,
Elad.