List of utility methods to do Image Flip
void | flipImage(int stride, int height, int b[]) flip Image int tmp[] = new int[stride]; for (int row = 0; row < height / 2; row++) { int rowa = row; int rowb = height - 1 - rowa; System.arraycopy(b, rowa * stride, tmp, 0, stride); System.arraycopy(b, rowb * stride, b, rowa * stride, stride); System.arraycopy(tmp, 0, b, rowb * stride, stride); |
Object | flipImage(Object nativeImage, boolean flipHorizontal, boolean flipVertical) flip Image throw new RuntimeException(); |
Image | flipImageVertically(Image img) Flips an image vertically. int w = img.getWidth(null); int h = img.getHeight(null); BufferedImage bimg = toBufferedImage(getEmptyImage(w, h)); Graphics2D g = bimg.createGraphics(); g.drawImage(img, 0, 0, w, h, 0, h, w, 0, null); g.dispose(); return toImage(bimg); |
int[] | flipPixels(int[] imgPixels, int imgw, int imgh) Flip an array of pixels vertically int[] flippedPixels = null; if (imgPixels != null) { flippedPixels = new int[imgw * imgh]; for (int y = 0; y < imgh; y++) { for (int x = 0; x < imgw; x++) { flippedPixels[((imgh - y - 1) * imgw) + x] = imgPixels[(y * imgw) + x]; return flippedPixels; |