In Java, instead of using photoshop to transform my images(that I use in the program), I want to use code to transform and save them.
I have created an AffineTransform object "at" and called the rotate()
method. I have a BufferedImage called "image".
I can draw the image on the screen with the desired transformation with this code:
g2d.drawImage(image, at, null);
What I want to do is to store the combination of at and image in a new BufferedImage image2. How can I do this so thatg2d.drawImage(image2,50,50, null);
will show the rotated version of image?
edit: I've tweaked Ezequiel's answer a bit to get the effect I wanted. This did the trick:
BufferedImage image2= null;
AffineTransformOp affineTransformOp = new AffineTransformOp(at,AffineTransformOp.TYPE_BILINEAR);
image2 = affineTransformOp.filter(image, image2);
g2d.drawImage(image2, 50, 50, null);