Lesen und Schreiben von TIFF-Bildern in Java
Ich habe den folgenden Code ausprobiert, um die Aufgabe des Lesens und Schreibens von Tiff-Bildern zu erfüllen:
// Define the source and destination file names.
String inputFile = /images/FarmHouse.tif
String outputFile = /images/FarmHouse.bmp
// Load the input image.
RenderedOp src = JAI.create("fileload", inputFile);
// Encode the file as a BMP image.
FileOutputStream stream =
new FileOutputStream(outputFile);
JAI.create("encode", src, stream, BMP, null);
// Store the image in the BMP format.
JAI.create("filestore", src, outputFile, BMP, null);
Beim Ausführen des Codes wird jedoch die folgende Fehlermeldung angezeigt:
Caused by: java.lang.IllegalArgumentException: Only images with either 1 or 3 bands
can be written out as BMP files.
at com.sun.media.jai.codecimpl.BMPImageEncoder.encode(BMPImageEncoder.java:123)
at com.sun.media.jai.opimage.EncodeRIF.create(EncodeRIF.java:79)
Ich habe eine Idee, wie ich dieses Problem lösen könnte?