Hallöchen zusammen,
ich stehe mal wieder vor einem Problem, ich möchte ein eingelesenes Bild, welches garantiert quadratisch ist, in 16 gleich große Subimages teilen.
Mein Ansatz ist folgender:
Jedoch funktioniert es nicht, und ich erhalte bei der Ausführung eine java.awt.image.RasterFormatException: (y + height) is outside of Raster
Kann sich das jemand erklären?
Vielen Dank für Eure Hilfe.
Liathne
ich stehe mal wieder vor einem Problem, ich möchte ein eingelesenes Bild, welches garantiert quadratisch ist, in 16 gleich große Subimages teilen.
Mein Ansatz ist folgender:
Code:
public static void cropLvlOne(BufferedImage img, File file, String output) throws Exception{
BufferedImage bi;
int width = img.getWidth();
int heigth = img.getHeight();
for (int x = 0; x < 4; x++) {
for (int y = 3; y >= 0; y--) {
bi = img.getSubimage(x * (img.getWidth() / 4), y * (img.getHeight() / 4), (x + 1) * (img.getWidth() / 4), (y + 1) * (img.getHeight() / 4));
String filename = file.getName();
filename = filename.substring(0, filename.length()-4);
filename += "_00_"+x+(3-y);
String outputdir = output+File.separatorChar+filename+".bmp";
ImageIO.write(bi, "bmp", new File( outputdir ) );
}
}
}
Jedoch funktioniert es nicht, und ich erhalte bei der Ausführung eine java.awt.image.RasterFormatException: (y + height) is outside of Raster
Kann sich das jemand erklären?
Vielen Dank für Eure Hilfe.
Liathne