PDA

View Full Version : image reducing



rogersilva
03-12-2002, 02:33 AM
is there a way to reduce the resolution of image using openGL functions???

Thanks.

zeckensack
03-12-2002, 02:40 AM
No. But the glu can do that.

zeckensack
03-12-2002, 03:05 AM
First, you need to include the glu header and lib into your project (just like you did with gl.h and opengl32.lib).

Then you can use this function:

3.1 Image Scaling
The following routine magnifies or shrinks an image:
int gluScaleImage(format,widthin,heightin,typein,*data in,widthout,heightout,typeout,*dataout );

gluScaleImage will scale an image using the appropriate pixel store
modes to unpack data from the input image and pack the result into the
output image. format speci
es the image format used by both images. The
input image is described by widthin, heightin, typein, and datain, where
widthin and heightin specify the size of the image, typein speci
es the data
type used, and datain is a pointer to the image data in memory. The output
image is similarly described by widthout, heightout, typeout, and dataout,
where widthout and heightout specify the desired size of the image, typeout
speci
es the desired data type, and dataout points to the memory location
where the image is to be stored. The pixel formats and types supported are the same as those supported by glDrawPixels for the underlying OpenGL
implementation.

Looks a little overwhelming at first, but all the pixel storage stuff is very similar to what you need for texturing, so it shouldn't be so hard to figure it out.

The complete glu spec is here (ftp://ftp.sgi.com/opengl/doc/opengl1.2/glu1.3.pdf) .

*edit* Aargh, stupid Acrobat Reader mangled the text!

[This message has been edited by zeckensack (edited 03-12-2002).]

rogersilva
03-12-2002, 03:12 AM
Please, how can i reduce the image size using openGL or glu???
(im trying to reduce a 28X28 image to 4X4)
Thanks.


Originally posted by zeckensack:
No. But the glu can do that.

zeckensack
03-12-2002, 03:17 AM
Originally posted by rogersilva:
Please, how can i reduce the image size using openGL or glu???
(im trying to reduce a 28X28 image to 4X4)
Thanks.



For 24bit rgb stuff, use this:
gluScaleImage(GL_RGB,28,28,GL_UNSIGNED_BYTE,pointe r_to_input_data,4,4,GL_UNSIGNED_BYTE,pointer_to_ou tput_data);