Java Image Flip flipImage(int stride, int height, int b[])

Here you can find the source of flipImage(int stride, int height, int b[])

Description

flip Image

License

LGPL

Declaration

public static void flipImage(int stride, int height, int b[]) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static void flipImage(int stride, int height, int b[]) {
        int tmp[] = new int[stride];

        for (int row = 0; row < height / 2; row++) {

            int rowa = row;
            int rowb = height - 1 - rowa;

            // swap rowa and rowb

            // tmp <-- rowa
            System.arraycopy(b, rowa * stride, tmp, 0, stride);

            // rowa <-- rowb
            System.arraycopy(b, rowb * stride, b, rowa * stride, stride);

            // rowb <-- tmp
            System.arraycopy(tmp, 0, b, rowb * stride, stride);
        }//  w  ww  .  j a  v a2s  . c  o m
    }
}

Related

  1. flipImage(Object nativeImage, boolean flipHorizontal, boolean flipVertical)
  2. flipImageVertically(Image img)
  3. flipPixels(int[] imgPixels, int imgw, int imgh)