Horizontal flip, vertical flip, and 180-degree rotation of swing Images

Source: Internet
Author: User
Tags image flip
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.