Displaying a part of BMP image

Hi all,
I am reading a BMP image and i am using glRasterpos and gldrawpixels to show the image on the opengl window.

However i would like to display a part of the BMP image that is being read. Can anybody help on how to achieve this.

Thanks in advance

int BMPwidth = 256;
int BMPheight = 256;

//display rectangle from bottom left (128,128) to top right(256,256)

int bottom = 128;
int top = 256;

int left = 128;
int right = 256;

glPixelStorei(GL_UNPACK_SKIP_ROWS ,bottom);
glPixelStorei(GL_UNPACK_SKIP_PIXELS,left);
glPixelStorei(GL_UNPACK_ROW_LENGTH ,BMPwidth);

glDrawPixels(right-left, top-bottom, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)data);

Hi,
Thanks for the reply.
I am using a color BMP image of size 184 X 92 size. It contains
24 images so each image 23 X 23. So there are 8 images per row.
You can consider it as a table of 8 columns and 4 rows each one being 23 X 23. If i want to display each of the images separately
what parameters should i give for the glPixelstorei. could you help me on this.

Thanks in advance.

//display row i, column j

glPixelStorei(GL_UNPACK_SKIP_ROWS ,i23);
glPixelStorei(GL_UNPACK_SKIP_PIXELS,j
23);
glPixelStorei(GL_UNPACK_ROW_LENGTH ,184);

glDrawPixels(23, 23, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)data);

That wasn’t so hard, was it? :wink:

Hi,
Thank you for your reply. I was able to display each image separately. Thanks.

Bye.