glScalef as it applies to scaling of a pixel image

Hi All,

A question with regard to glScalef:

I render an image of size X by X, and wish to shrink it down to size Y by Y. I perform glReadPixels to read in the X by X pixels, and command glScalef before using glBegin(GL_POINTS) to redraw the Y by Y image. The red book says that Scalef is based on matrix manipulation, i.e. works on object vertices.

The image looks a little blurred after glScalef has been used on the X by X pixels compared to just rendering a shrunk version of the original model so it comes out as Y by Y pixels in the first place, so something is happening to the pixels due to glScalef.

Does glScalef command the image to be resampled from size X by X to Y by Y ??

Does anyone know of any command that enables the Y by Y image to be produced via averaging of the X by X pixels rather than just resampling to achieve the shrink?

Thanks in advance.

Tim Sills

From what I understand it does not resample your image, or resize, it just effects the cordinates where it is displayed. You should probully bind the image to a quad first(i.e. texture map it), and use it as such.

What you say is a good idea, however even the MIPMAP type filtering won’t let me produce what I want and need (which is at hundreds of frames/sec).

I thought that glScalef might operate this way:

Say you have a 100 by 100 image. Say you also want a 3.2 by 6.5 image. Obviously you can’t physically achieve those odd dimensions so you would see something like 4 by 7. The trick is how to get the same average colour in those 4 by 7 pixels that you would have in your 3.2 by 6.5.

You read in the pixels, command glScalef with the relevant numbers, and the system treats the pixels as the smallest possible quads that can be drawn, so in effect the pixels become tiny 2D objects. When asked for an image downsize via floating point scaling, the system produces 3 by 6 fully occupied pixels in this case, whereas the fractional quads colour the pixels they touch via something like area-averaging so the whole pixel is coloured up, hence the 4 by 7 result.

I know it’s a stab in the dark, and it becomes even more so when the literature does not specifically say that area-based anti-aliasing and blending must be enabled when using glScalef, but it’s the best educated guess I can make right now and this level of detail is fundamental to my work.

Has anyone seen comments in the literature about glScalef and TWO dimensional images?! The red book mentions glScalef before drawing pixels in Chapter 14, under “Cheap Image Transformation” (version 1.2, third edition), so there has to be some link between glScalef and pixels. What is this link is my ultimate question. Resampling? Area-averaging? Filtration of some sort?!

Thx for the suggestion

Tim Sills