We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Flip Image? (Read 3933 times)
Flip Image?
Feb 21st, 2008, 4:20pm
 
Hello,

Is there any method in the processing API to draw a flipped image (e.g. reversed in either X-axis, Y-axis, or both?)

The usual method to do this in Java, e.g. to invert either the source dimensions or the destination dimensions, do not work in Processing (seemingly intentionally).

Thanks!
Re: Flip Image?
Reply #1 - Feb 21st, 2008, 5:19pm
 
You can use scale() to do this:

Code:

pushMatrix();
scale(-1.0, 1.0);
image(img,-img.width,0);
popMatrix;


or you can walk through the pixels and reverse them manually



Re: Flip Image?
Reply #2 - Feb 21st, 2008, 10:40pm
 
That works exactly as desired, thanks.
Re: Flip Image?
Reply #3 - Nov 21st, 2009, 12:56pm
 
Daniel Shiffman wrote on Feb 21st, 2008, 5:19pm:
You can use scale() to do this:

Code:

pushMatrix();
scale(-1.0, 1.0);
image(img,-img.width,0);
popMatrix;



Thanks for this, however, there was just one small mistake with the code...
popMatrix; should be  popMatrix();
Page Index Toggle Pages: 1