39 lines
1.1 KiB
Java
39 lines
1.1 KiB
Java
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 {
|
|
/**
|
|
* spiegeleHorizontal spiegelt das Bild, so dass rechts und links getauscht werden
|
|
*
|
|
* @param originalbild Ein Bild (Picture), das gespiegelt werden soll
|
|
* @return Eine gespiegelte Kopie des Bildes
|
|
*/
|
|
public static Picture mirror(Picture originalbild) {
|
|
int breite = originalbild.getWidth();
|
|
int hoehe = originalbild.getHeight();
|
|
|
|
Color[][] pixel = originalbild.getPixelArray();
|
|
Color[][] pixelNeu = new Color[breite][hoehe];
|
|
|
|
for (int x = 0; x < breite; x++) {
|
|
for (int y = 0; y < hoehe; y++) {
|
|
pixelNeu[x][y] = pixel[(breite - 1) - x][y];
|
|
}
|
|
}
|
|
|
|
Picture neuesBild = new Picture();
|
|
neuesBild.setPixelArray(pixelNeu);
|
|
return neuesBild;
|
|
}
|
|
}
|