Guru's - DIB sections?

I posted this message on the Beginners board but there was no real solution. I need to load only parts of a bitmap at a time into memory.:

Can anyone suggest a way to read in a part of a bitmap into a texture. The image that I’m loading is 1Gb so I can’t load the whole image, as it’s so big and it would slow my processes down.
I’m currently using :
AUX_RGBImageRec *texture1;
texture1 = auxDIBImageLoad(“Data/bit.bmp”);

Is there a auxDIB section load?

Thanks
Patrick

If you have space to load the entire image data into memory, then you can specify UNPACK_ROW_LENGTH before uploading part of the image with glTex{Sub}Image2D. I e, if there’s 3111 pixels across, each is 4 bytes, and you want to upload 512*512 of them at position x, y, you’d do something this:

unsigned char const * data = your image;
glPixelStorei( GL_UNPACK_ROW_LENGTH, 31114 );
glTexImage2D( GL_TEXTURE_2D, 0, 512, 512, 0, GL_BGRA, GL_UNSIGNED_BYTE, data+x
4+y31114 );

Thanks
Q.
when you state “your image” how do you suggest loading this?

Originally posted by jwatte:
[b]If you have space to load the entire image data into memory, then you can specify UNPACK_ROW_LENGTH before uploading part of the image with glTex{Sub}Image2D. I e, if there’s 3111 pixels across, each is 4 bytes, and you want to upload 512*512 of them at position x, y, you’d do something this:

unsigned char const * data = your image;
glPixelStorei( GL_UNPACK_ROW_LENGTH, 31114 );
glTexImage2D( GL_TEXTURE_2D, 0, 512, 512, 0, GL_BGRA, GL_UNSIGNED_BYTE, data+x
4+y31114 );

[/b]

The BMP file format is well documented. If you want to read just some sections of the file, the I suggest reading the parts (scanlines, or parts of scanlines) you need manually. This is neither OpenGL related nor an advanced topic, though, so we’d better stop here.
www.wotsit.org for file formats.