Java BufferedImage Flip flipAroundX(BufferedImage image)

Here you can find the source of flipAroundX(BufferedImage image)

Description

Flips the image horizontally

License

Creative Commons License

Parameter

Parameter Description
image image to flip

Return

Modified image

Declaration

public static BufferedImage flipAroundX(BufferedImage image) 

Method Source Code

//package com.java2s;
//License from project: Creative Commons License 

import java.awt.geom.AffineTransform;

import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;

public class Main {
    /**//from  ww  w . j  a  v  a  2  s  . c o m
     * Flips the image horizontally
     *
     * @param image image to flip
     * @return Modified image
     */
    public static BufferedImage flipAroundX(BufferedImage image) {
        // Flip the image vertically
        AffineTransform tx = AffineTransform.getScaleInstance(1, -1);
        tx.translate(0, -image.getHeight(null));
        AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
        image = op.filter(image, null);
        return image;
    }
}

Related

  1. flip(BufferedImage image, boolean flipHorizontal, boolean flipVertical)
  2. flip(BufferedImage image, int direction)
  3. flip(BufferedImage myImage, int type)
  4. flipBothVerticallyAndHorizontallyWithAffineTransformOp(BufferedImage srcImage)
  5. flipBufferedImage(BufferedImage bufferedImage)
  6. flipBufferedImageVertically(BufferedImage bufferedImage)
  7. flipHorizontal(BufferedImage bufferedImage)