package io.gitlab.jfronny.ImgJava.imageProcessing; import io.gitlab.jfronny.ImgJava.util.Picture; import java.awt.*; /** * Algorithmen zur Ă„nderung der Pixelpositionen eines Pictures * z.B. drehen, spiegeln usw. * * @author Thomas Schaller * @version 1.1 (28.11.2019) */ public class ImageUtil { /** * Horizontally mirrors an image (mutates original instance) * * @param picture Picture to mirror * @return The mirrored image */ public static Picture mirror(Picture picture) { int w = picture.getWidth(); int h = picture.getHeight(); Color[][] pixel = picture.getPixelArray(); Color[][] pixelNeu = new Color[w][h]; for (int x = 0; x < w; x++) { System.arraycopy(pixel[(w - 1) - x], 0, pixelNeu[x], 0, h); } picture.setPixelArray(pixelNeu); return picture; } }