View Full Version : Mirroring an image

12-31-2004, 02:59 AM
I want to try to mirror an image, but it didn't work. I used the command
glReadPixels to import the picture in the buffer and now I have to mirror

I tried this with the command glScalef(1,-1,1); but it didn't work. I have
to refer to the image buffer, right? But how does it work?

JSAMPLE * image_buffer=new JSAMPLE[582*500*3];
glReadPixels(0,0,582,500,GL_RGB,GL_UNSIGNED_BYTE,i mage_buffer);
write_JPEG_file ("test.jpg",100,image_buffer,582,500);
delete image_buffer;

Thanks and a happy new year!

12-31-2004, 09:00 AM
This is a beginner question but I'll answer anyway. glScalef is a function that applies a scale transformation to the modelview matrix which obviously is multiplied by your vertices as they are processed. You are not (from what I can tell) using any geometry at all so your scaling transform does nothing (nothing to your image that is). To do what you want doesn't even need OpenGL at all. To flip vertically just swap the first and last rows, second and second to last, third and third to last, etc...