Java BufferedImage Flip flipImage(Object original, boolean flipX, boolean flipY)

Here you can find the source of flipImage(Object original, boolean flipX, boolean flipY)

Description

flip Image

License

Open Source License

Declaration

public static BufferedImage flipImage(Object original, boolean flipX, boolean flipY) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.image.BufferedImage;
import java.awt.Graphics2D;

public class Main {
    public static BufferedImage flipImage(Object original, boolean flipX, boolean flipY) {
        BufferedImage originalImage = (BufferedImage) original;
        if (!flipX && !flipY)
            return originalImage;
        int x = 0;
        int y = 0;
        int width = originalImage.getWidth();
        int height = originalImage.getHeight();
        BufferedImage flippedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = flippedImage.createGraphics();
        if (flipX) {
            x = width;//  w  ww  .j  a  v  a2 s. c  o m
            width = -width;
        }
        if (flipY) {
            y = height;
            height = -height;
        }
        g.drawImage(originalImage, x, y, width, height, null);
        g.dispose();
        return flippedImage;
    }
}

Related

  1. flipBufferedImageVertically(BufferedImage bufferedImage)
  2. flipHorizontal(BufferedImage bufferedImage)
  3. flipHorizontally(BufferedImage srcImage)
  4. flipImage(BufferedImage image)
  5. flipImage(final BufferedImage image, final boolean horizontal, final boolean vertical)
  6. flipImageHorizontally(BufferedImage image)
  7. flipImageVertically(BufferedImage theImage)
  8. flipVertical(BufferedImage im)
  9. flipVertically(BufferedImage image)