PDA

View Full Version : Mirroring an image



mk
12-31-2004, 03:59 AM
Hi!
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
it.

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?

Code:
JSAMPLE * image_buffer=new JSAMPLE[582*500*3];
glPixelStorei(GL_PACK_ALIGNMENT,1);
glReadPixels(0,0,582,500,GL_RGB,GL_UNSIGNED_BYTE,i mage_buffer);
glScalef(1,-1,1);
write_JPEG_file ("test.jpg",100,image_buffer,582,500);
delete image_buffer;

Thanks and a happy new year!

SirKnight
12-31-2004, 10: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...

-SirKnight