/** * Save a single image to the specified file * * @param image * @throws IOException * @throws FormatException */ public static void saveImage(IcyBufferedImage image, File file, boolean force) throws FormatException, IOException { final IFormatWriter writer = getWriter(file, ImageFileFormat.TIFF); if (writer == null) throw new UnknownFormatException( "Can't find a valid image writer for the specified file: " + file); final boolean separateChannel = getSeparateChannelFlag(writer, image.getIcyColorModel()); try { writer.setMetadataRetrieve(MetaDataUtil.generateMetaData(image, separateChannel)); } catch (ServiceException e) { System.err.println("Saver.saveImage(...) error :"); IcyExceptionHandler.showErrorMessage(e, true); } // get byte order final boolean littleEndian = !writer.getMetadataRetrieve().getPixelsBinDataBigEndian(0, 0).booleanValue(); // then save the image saveImage( writer, image.getRawData(littleEndian), image.getSizeX(), image.getSizeY(), image.getSizeC(), separateChannel, image.getDataType_(), file, force); }