Here you can find the source of flip(BufferedImage image, boolean flipHorizontal, boolean flipVertical)
public static BufferedImage flip(BufferedImage image, boolean flipHorizontal, boolean flipVertical)
//package com.java2s; //License from project: Open Source License import java.awt.Point; import java.awt.geom.AffineTransform; import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; public class Main { /** the graphic2d changes, must use the new one for future operations. use image.createGraphics(); */ public static BufferedImage flip(BufferedImage image, boolean flipHorizontal, boolean flipVertical) { Point scale = new Point(1, 1); Point translate = new Point(0, 0); if (flipHorizontal) { scale.x = -1;/*from w w w .j a v a 2 s .co m*/ translate.x = -image.getWidth(); } if (flipVertical) { scale.y = -1; translate.y = -image.getHeight(); } AffineTransform tx = AffineTransform.getScaleInstance(scale.x, scale.y); tx.translate(translate.x, translate.y); AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); return op.filter(image, null); } }