View Full Version : Displaying a part of BMP image
xyz123456
04-01-2008, 10:35 AM
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
-NiCo-
04-01-2008, 01:20 PM
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);
xyz123456
04-01-2008, 08:17 PM
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.
-NiCo-
04-02-2008, 12:18 AM
//display row i, column j
glPixelStorei(GL_UNPACK_SKIP_ROWS ,i*23);
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? ;)
xyz123456
04-02-2008, 03:14 AM
Hi,
Thank you for your reply. I was able to display each image separately. Thanks.
Bye.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.