}
public static boolean save(int type, ImagePlus ip, File outputFile) {
switch (type) {
case Opener.TIFF:
return new FileSaver(ip).saveAsTiff(outputFile.getPath());
case Opener.GIF:
return new FileSaver(ip).saveAsGif(outputFile.getPath());
case Opener.JPEG:
return new FileSaver(ip).saveAsJpeg(outputFile.getPath());
case Opener.TEXT:
return new FileSaver(ip).saveAsText(outputFile.getPath());
case Opener.LUT:
return new FileSaver(ip).saveAsLut(outputFile.getPath());
case Opener.ZIP:
return new FileSaver(ip).saveAsZip(outputFile.getPath());
case Opener.BMP:
return new FileSaver(ip).saveAsBmp(outputFile.getPath());
case Opener.PNG:
ImagePlus tempImage = WindowManager.getTempCurrentImage();
WindowManager.setTempCurrentImage(ip);
PlugIn p =null;
try {
p = (PlugIn) Class.forName("ij.plugin.PNG_Writer").newInstance();
} catch (InstantiationException e) {
logger.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
logger.error(e.getMessage(), e);
} catch (ClassNotFoundException e) {
logger.error(e.getMessage(), e);
}
p.run(outputFile.getPath());
WindowManager.setTempCurrentImage(tempImage);
return true;
case Opener.PGM:
return new FileSaver(ip).saveAsPgm(outputFile.getPath());
}
return false;
}