Java BufferedImage Operation symmetrifyY(BufferedImage image, boolean useFirstHalfImage, boolean flipVertical)

Here you can find the source of symmetrifyY(BufferedImage image, boolean useFirstHalfImage, boolean flipVertical)

Description

symmetrify Y

License

Open Source License

Declaration

public static BufferedImage symmetrifyY(BufferedImage image, boolean useFirstHalfImage, boolean flipVertical) 

Method Source Code

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

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage symmetrifyY(BufferedImage image, boolean useFirstHalfImage, boolean flipVertical) {
        int halfWidth = image.getHeight() / 2;
        int startReadPosition = 0;
        int startWritePosition = 0;
        int endWritePosition = image.getHeight() - 1;

        if (!useFirstHalfImage)
            startReadPosition = halfWidth;
        if (!useFirstHalfImage ^ flipVertical)//xor 
        {// ww  w . j  a  v  a2  s . c  o m
            startWritePosition = halfWidth;
            endWritePosition = halfWidth;
        }

        BufferedImage returned = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
        for (int i = 0; i < image.getWidth(); i++) {
            for (int j = 0; j < image.getHeight() / 2; j++) {
                int color = image.getRGB(i, startReadPosition + j);
                returned.setRGB(i, startWritePosition + j, color);
                returned.setRGB(i, endWritePosition - j, color);
            }
        }
        return returned;
    }
}

Related

  1. showColors(BufferedImage image, boolean alpha, boolean red, boolean green, boolean blue)
  2. shrink(BufferedImage source, double factor)
  3. smaller(final BufferedImage src, final int radius, final int opaqueLimit)
  4. stitchImages(BufferedImage[] images, int[] relX)
  5. switchAxes(BufferedImage img)
  6. testNeighbours(BufferedImage source, int x, int y, boolean alpha)
  7. texture2D(BufferedImage normalMap, int x, int y)
  8. thresholdImage(BufferedImage image, int threshold)
  9. tile(BufferedImage source, Rectangle r, GraphicsConfiguration conf)