horizontal flip BufferedImage - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Rotate

Description

horizontal flip BufferedImage

Demo Code


//package com.java2s;

import java.awt.image.*;
import java.awt.*;

public class Main {
    public static BufferedImage horizontalflip(BufferedImage img) {
        int w = img.getWidth();
        int h = img.getHeight();
        BufferedImage dimg = new BufferedImage(w, h, img.getColorModel()
                .getTransparency());/*w w  w .j  av  a2 s. c  o m*/
        Graphics2D g = dimg.createGraphics();
        g.drawImage(img, 0, 0, w, h, w, 0, 0, h, null);
        g.dispose();
        return dimg;
    }
}

Related Tutorials