Hi Everyone,
I've got a class thtat grabs a frame from an avi file to Bitmap class. Then I pass the Bitmap to another class which should convert it to OpenGL texture. The problem is that when I try to use LockBits function, I get access violation exception.
It's like this:
b = video.GetFrame();
gpu.CreateTexture(b);
where GetFrame() returns:
Bitmap b = new Bitmap(width, height, linesize, PixelFormat.Format24bppRgb, bufferPtr);
return b;
and
public void CreateTexture(Bitmap bitmap)
{
int[] texture = new int[1];
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST);
Gl.glGenTextures(1, texture);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture[0]);
int w = bitmap.Width;
int h = bitmap.Height;
BitmapData data = bitmap.LockBits(new Rectangle(0, 0, w, h),
ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); //Here I get the error
(...)
}
What am I doing wrong? Ahh, I'm using Tao Framework to access OpenGL functions.
--
Best regards,
Mateusz