Sign in to follow this  

Mirroring an JPEG-image

This topic is 4733 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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,image_buffer); glScalef(1,-1,1); write_JPEG_file ("test.jpg",100,image_buffer,582,500); delete image_buffer; Thanks and a happy new year!

Share this post


Link to post
Share on other sites
Mirror the image buffer before write your jpeg file...?!?

something like this


//FlipX
for(y=0; y<height; y++){
for(x=0; x<width/2; x++){
SwapPixels(x,y, width-x-1,y);
}
}

//FlipY
for(x=0; x<width; x++){
for(y=0; y<height/2; y++){
SwapPixels(x,y, x,height-y-1);
}
}


Share this post


Link to post
Share on other sites

This topic is 4733 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this