*
* @param image image to write
* @param file path and file name (extension will be ignored and changed to tiff.
*/
public static void writeUncompressedImage(BufferedImage image, String file) throws IOException {
FileImageOutputStream out = null;
try {
final File parentFile = new File(file).getParentFile();
Iterator<ImageWriter> writers = ImageIO.getImageWritersBySuffix("tiff");
final ImageWriter next = writers.next();
final ImageWriteParam param = next.getDefaultWriteParam();
param.setCompressionMode(ImageWriteParam.MODE_DISABLED);
final File outputFile = new File(parentFile, Files.getNameWithoutExtension(file) + ".tiff");
out = new FileImageOutputStream(outputFile);
next.setOutput(out);
next.write(image);
} catch (Throwable e) {
System.err.println("Error writing the image generated by the test:" + file + "\n\t");
e.printStackTrace();
} finally {
if (out != null) {
out.close();
}
}
}