Import Java. AWT. geom. affinetransform; import Java. AWT. image. affinetransformop; import Java. AWT. image. bufferedimage; import Java. io. fileinputstream; import Java. io. ioexception; import javax. imageIO. imageIO; import javax. swing. imageicon; import javax. swing. jframe; import javax. swing. jlabel; import javax. swing. jtabbedpane;/*** make the image flip horizontally, flip vertically, rotate 180 degrees * @ author administrator */public class testpicture {public static void main (string [] ARGs) throws ioexception {bufferedimage sourceimage = ImageIO. read (New fileinputstream ("title4.gif"); bufferedimage dstimage = NULL; affinetransform transform = new affinetransform (-, sourceimage. getwidth ()-); // flip horizontally // affinetransform transform = new affinetransform (, 0,-, sourceimage. getheight ()-1); // vertical flip // affinetransform transform = new affinetransform (-1, 0,-1, sourceimage. getwidth ()-1, sourceimage. getheight ()-1); // rotate 180 degrees affinetransformop op = new affinetransformop (transform, affinetransformop. type_bilinear); dstimage = op. filter (sourceimage, null); jtabbedpane tabbedpane = new jtabbedpane (); tabbedpane. add ("Source transform", new jlabel (New imageicon (sourceimage); tabbedpane. add ("affine transform", new jlabel (New imageicon (dstimage); jframe = new jframe (); jframe. setsize (800,600); jframe. setdefaclocloseoperation (jframe. exit_on_close); jframe. getcontentpane (). add (tabbedpane); jframe. setvisible (true );}}
The affinetransform class represents 2D affine transformations, which perform linear ing from 2D coordinates to other 2D coordinates, retaining the line's "Linearity" and "parallelism ". You can use a series of translation, scaling, flip, rotation, and shear operations to construct an affine transformation.