I am trying to rotate an animated gif stored in an ImageIcon using an AffineTransform. The result is that the image does not get drawn.
Here's my code:
AffineTransform trans = AffineTransform.getRotateInstance(imgYaw, img.getImage().getWidth(null) / 2, img.getImage().getHeight(null) / 2);
AffineTransformOp transo = new AffineTransformOp(trans, AffineTransformOp.TYPE_BILINEAR);
BufferedImage bufferedimg = new BufferedImage(img.getImage().getWidth(null), img.getImage().getHeight(null), BufferedImage.TYPE_4BYTE_ABGR);
img.setImage(atransO.filter(bufferedimg, null));
img.paintIcon(null, g, x, y);
Not so much an answer, but an example of simplified workflow...
Basically, what this does is applies a
AffineTransform
directly to theGraphics
context and paints theIconImage
to it...Now, you could use the
Graphics
context fromBufferedImage
if that's what you need...