flip Image Horizontal - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Rotate

Description

flip Image Horizontal

Demo Code


//package com.java2s;

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage flipImageHorizontal(BufferedImage image) {
        BufferedImage imageFlipped = new BufferedImage(image.getWidth(),
                image.getHeight(), image.getType());
        for (int y = 0; y < image.getHeight(); y++) {
            for (int x = 0; x < image.getWidth(); x++) {
                imageFlipped.setRGB(x, y, image.getRGB(63 - x, y));
            }/*from   www.j a va 2 s . c  o m*/
        }
        return imageFlipped;
    }
}

Related Tutorials