Drawing image flipped

Is it proper to draw an image with a negative width/height in order to flip it.

I’m asking because it’s working on my machine and anyother windows machine I’ve tried it on. But it’s not really a part of any documentation that I’ve seen or even a tutorial(that I remember). Which means that I’m curious if it’s something that will work the same on every system, or just some strange OS/Hardware behavior semi-unique to the 3 computers I’ve tried it on.

yeah why not, you can rotate an image negative, so why not draw it negative. If it works then it works. there might be better methods though.

I have no idea if that’s “bad,” but I’ve never heard of anyone doing it and because yours is counter-intuitive (and probably abuses a bug) it’s probably better to use the “correct” method.

g.drawImage with source and destination vertices.

Basically you do this:


//Flipped horizontal
g.drawImage(myImage, x, y, x+width, y+height, x+width, y, x, y+height, null);
//Flipped vertical
g.drawImage(myImage, x, y, x+width, y+height, x, y+height, x+width, y, null);
//Flipped both
g.drawImage(myImage, x, y, x+width, y+height, x+width, y+height, x, y, null);

Have a look here : Flip and draw an image by graphics.drawImage(…): Any issues known? http://forums.java.net/jive/thread.jspa?threadID=57788&tstart=45

August

Its okay to do so. Drawing an image with negative width or height does a mirror effect, which is not equal to a rotation.

-JAW