Java BufferedImage Operation mirror(final BufferedImage image, final boolean horizontal)

Here you can find the source of mirror(final BufferedImage image, final boolean horizontal)

Description

mirror

License

Open Source License

Declaration

public static BufferedImage mirror(final BufferedImage image, final boolean horizontal) throws Exception 

Method Source Code

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

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage mirror(final BufferedImage image, final boolean horizontal) throws Exception {
        int width = image.getWidth();
        int height = image.getHeight();

        BufferedImage output = new BufferedImage(image.getHeight(), image.getWidth(), image.getType());
        for (int i = 0; i < width; i++) {
            for (int j = 0; j < image.getHeight(); j++) {
                if (horizontal) {
                    output.setRGB(width - i - 1, j, image.getRGB(i, j));
                } else {
                    output.setRGB(i, height - j - 1, image.getRGB(i, j));
                }//from www. j  a  va 2 s  . com
            }
        }
        return output;
    }
}

Related

  1. MakePoly(BufferedImage spr, int d, int angle, int baseX, int baseY)
  2. makeTintedCopy(BufferedImage bi, Color tint)
  3. markImageBorders(final BufferedImage img, final int startW, final int startH)
  4. matBytesToBufferedImage(byte[] data, int cols, int rows, int type)
  5. matte(BufferedImage image, int top, int bottom, int left, int right, Color bg)
  6. newOptimizedImageLike(GraphicsConfiguration destination, BufferedImage img)
  7. newSubimage(BufferedImage src, int x, int y, int w, int h)
  8. nNeighbors(BufferedImage image, int i, int j)
  9. nrChannels(BufferedImage img)