PDA

View Full Version : Guru's - DIB sections?



A05087
11-28-2002, 08:23 AM
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

jwatte
11-28-2002, 08:47 AM
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, 3111*4 );
glTexImage2D( GL_TEXTURE_2D, 0, 512, 512, 0, GL_BGRA, GL_UNSIGNED_BYTE, data+x*4+y*3111*4 );

A05087
11-28-2002, 08:58 AM
Thanks
Q.
when you state "your image" how do you suggest loading this?


Originally posted by jwatte:
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, 3111*4 );
glTexImage2D( GL_TEXTURE_2D, 0, 512, 512, 0, GL_BGRA, GL_UNSIGNED_BYTE, data+x*4+y*3111*4 );

jwatte
11-28-2002, 07:54 PM
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 (http://www.wotsit.org) for file formats.