Image flipping

Hi

I’m trying to flip 2D images in java using this code:


g.drawImage (img,
             0, img.getHeight(this), 0,im.getWidth(this),
             0, 0, im.getWidth(this), im.getHeight(this),
             this);

This works but it seems not accelerated! :o

If I don’t flip the image i get 110fps, when I flip it
I get 90fps.

There’s another way to do image flipping in the
hardware accelerated way???

Many thanks.

Unfortunately, currently we do not accelerate such operations.

You can try to cache your flipped image to somewhat improve the speed (so you won’t need to flip it on each frame), if that’s possible.

Yes…

But the problem is with the flipped image…
I really don’t know how to mantain the transparence
of the source image. :-/

I’m sorry, I don’t seem to follow your problem. Could you please elaborate a bit more on what you’re trying to achieve and what’s not working?

I think this is what your looking for javacoder,

To maintain the alpha channel of the source image when drawing an image,
simply set the composite of the destination Graphics context like this :-


void flipImage(Image src, Image dst)
{
   Graphics2D g2 = (Graphics2D)dst.getGraphics();

   g2.setComposite(AlphaComposite.Src);

   g2.drawImage(src,
   0, src.getHeight(this), 0,src.getWidth(this), 
   0, 0, src.getWidth(this), src.getHeight(this), 
   this);

   g2.dispose();
}