ini.trakem2.io
Class ImageSaver

java.lang.Object
  extended by ini.trakem2.io.ImageSaver

public class ImageSaver
extends java.lang.Object

Provides the necessary thread-safe image file saver utilities.


Field Summary
static java.awt.image.IndexColorModel RGBA_COLOR_MODEL
           
 
Method Summary
static java.awt.image.BufferedImage createARGBImage(int[] pixels, int width, int height)
           
static java.awt.image.BufferedImage createGrayImage(byte[] pixels, int width, int height)
           
static void debugAlpha()
           
static java.lang.String getDescriptionString(ij.ImagePlus imp, ij.io.FileInfo fi)
          Returns a string containing information about the specified image.
static java.awt.image.BufferedImage openGreyImage(java.lang.String path)
           
static java.awt.image.BufferedImage openGreyJpeg(java.lang.String path)
           
static java.awt.image.BufferedImage openGreyTIFF(java.lang.String path)
           
static java.awt.image.BufferedImage openImage(java.lang.String path, boolean ensure_premultiplied_alpha)
          Open an image file including the alpha channel if it has one; will open JPEG, PNG and BMP.
static java.awt.image.BufferedImage openJpeg(java.lang.String path, boolean as_grey)
           
static java.awt.image.BufferedImage openJpegAlpha(java.lang.String path)
          Open a jpeg file including the alpha channel if it has one.
static java.awt.image.BufferedImage openJpegFromStream(java.io.InputStream stream, boolean as_grey)
          The stream IS NOT closed by this method.
static java.awt.image.BufferedImage openPNGAlpha(java.lang.String path)
           
static java.awt.image.BufferedImage openTIFF(java.lang.String path, boolean ensure_premultiplied_alpha)
          Opens RGB or RGB + alpha images stored in TIFF format.
static boolean saveAsARGBJpeg(int[] pixels, int width, int height, java.lang.String path, float quality)
          Save as ARGB jpeg.
static boolean saveAsGreyJpeg(byte[] pixels, int width, int height, java.lang.String path, float quality)
           
static boolean saveAsJpeg(java.awt.image.BufferedImage bi, java.lang.String path, float quality, boolean as_grey)
          Will not flush the given BufferedImage.
static boolean saveAsJpeg(ij.process.ImageProcessor ip, java.lang.String path, float quality, boolean as_grey)
          Returns true on success.
Core functionality adapted from ij.plugin.JpegWriter class by Wayne Rasband.
static boolean saveAsJpegAlpha(java.awt.image.BufferedImage awt, java.lang.String path, float quality)
          Save an RGB jpeg including the alpha channel if it has one; can be read only by ImageSaver.openJpegAlpha method; in other software the alpha channel is confused by some other color channel.
static boolean saveAsJpegAlpha(java.awt.Image awt, java.lang.String path, float quality)
          Save an RGB jpeg including the alpha channel if it has one; can be read only by ImageSaver.openJpegAlpha method; in other software the alpha channel is confused by some other color channel.
static boolean saveAsPNG(java.awt.image.BufferedImage awt, java.lang.String path)
          Save a PNG with or without alpha channel with default compression at maximum level (9, expressed as 0 in the ImageWriter compression quality because 0 indicates "maximum compression is important").
static boolean saveAsPNG(ij.process.ImageProcessor ip, java.lang.String path)
           
static boolean saveAsPNG(java.awt.Image awt, java.lang.String path)
           
static boolean saveAsTIFF(java.awt.image.BufferedImage bi, java.lang.String path, boolean as_grey)
           
static boolean saveAsTIFF(ij.process.ImageProcessor ip, java.lang.String path, boolean as_grey)
          WARNING fails when there is an alpha channel: generates an empty file.
static boolean saveAsTIFF(java.awt.Image awt, java.lang.String path, boolean as_grey)
          Will not flush @param awt.
static boolean saveAsZip(ij.ImagePlus imp, java.lang.String path)
          Returns true on success.
Core functionality adapted from ij.io.FileSaver class by Wayne Rasband.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RGBA_COLOR_MODEL

public static final java.awt.image.IndexColorModel RGBA_COLOR_MODEL
Method Detail

saveAsJpeg

public static final boolean saveAsJpeg(ij.process.ImageProcessor ip,
                                       java.lang.String path,
                                       float quality,
                                       boolean as_grey)
Returns true on success.
Core functionality adapted from ij.plugin.JpegWriter class by Wayne Rasband.


createGrayImage

public static final java.awt.image.BufferedImage createGrayImage(byte[] pixels,
                                                                 int width,
                                                                 int height)

saveAsGreyJpeg

public static final boolean saveAsGreyJpeg(byte[] pixels,
                                           int width,
                                           int height,
                                           java.lang.String path,
                                           float quality)

createARGBImage

public static final java.awt.image.BufferedImage createARGBImage(int[] pixels,
                                                                 int width,
                                                                 int height)

saveAsARGBJpeg

public static final boolean saveAsARGBJpeg(int[] pixels,
                                           int width,
                                           int height,
                                           java.lang.String path,
                                           float quality)
Save as ARGB jpeg.


saveAsJpeg

public static final boolean saveAsJpeg(java.awt.image.BufferedImage bi,
                                       java.lang.String path,
                                       float quality,
                                       boolean as_grey)
Will not flush the given BufferedImage.


openGreyJpeg

public static final java.awt.image.BufferedImage openGreyJpeg(java.lang.String path)

openJpeg

public static final java.awt.image.BufferedImage openJpeg(java.lang.String path,
                                                          boolean as_grey)

openJpegFromStream

public static final java.awt.image.BufferedImage openJpegFromStream(java.io.InputStream stream,
                                                                    boolean as_grey)
The stream IS NOT closed by this method.


saveAsZip

public static final boolean saveAsZip(ij.ImagePlus imp,
                                      java.lang.String path)
Returns true on success.
Core functionality adapted from ij.io.FileSaver class by Wayne Rasband.


getDescriptionString

public static final java.lang.String getDescriptionString(ij.ImagePlus imp,
                                                          ij.io.FileInfo fi)
Returns a string containing information about the specified image.


saveAsJpegAlpha

public static final boolean saveAsJpegAlpha(java.awt.image.BufferedImage awt,
                                            java.lang.String path,
                                            float quality)
Save an RGB jpeg including the alpha channel if it has one; can be read only by ImageSaver.openJpegAlpha method; in other software the alpha channel is confused by some other color channel.


saveAsJpegAlpha

public static final boolean saveAsJpegAlpha(java.awt.Image awt,
                                            java.lang.String path,
                                            float quality)
Save an RGB jpeg including the alpha channel if it has one; can be read only by ImageSaver.openJpegAlpha method; in other software the alpha channel is confused by some other color channel.


openJpegAlpha

public static java.awt.image.BufferedImage openJpegAlpha(java.lang.String path)
Open a jpeg file including the alpha channel if it has one.


openPNGAlpha

public static java.awt.image.BufferedImage openPNGAlpha(java.lang.String path)

openImage

public static java.awt.image.BufferedImage openImage(java.lang.String path,
                                                     boolean ensure_premultiplied_alpha)
Open an image file including the alpha channel if it has one; will open JPEG, PNG and BMP.

Parameters:
ensure_premultiplied_alpha - when true, ALWAYS puts the loaded image into a TYPE_INT_ARGB_PRE, which ensures for example PNG images with an alpha channel but of TYPE_CUSTOM to be premultiplied as well.

openGreyImage

public static java.awt.image.BufferedImage openGreyImage(java.lang.String path)

debugAlpha

public static final void debugAlpha()

saveAsPNG

public static final boolean saveAsPNG(ij.process.ImageProcessor ip,
                                      java.lang.String path)

saveAsPNG

public static final boolean saveAsPNG(java.awt.Image awt,
                                      java.lang.String path)

saveAsPNG

public static final boolean saveAsPNG(java.awt.image.BufferedImage awt,
                                      java.lang.String path)
Save a PNG with or without alpha channel with default compression at maximum level (9, expressed as 0 in the ImageWriter compression quality because 0 indicates "maximum compression is important").


saveAsTIFF

public static final boolean saveAsTIFF(ij.process.ImageProcessor ip,
                                       java.lang.String path,
                                       boolean as_grey)
WARNING fails when there is an alpha channel: generates an empty file.


saveAsTIFF

public static final boolean saveAsTIFF(java.awt.Image awt,
                                       java.lang.String path,
                                       boolean as_grey)
Will not flush @param awt.


saveAsTIFF

public static final boolean saveAsTIFF(java.awt.image.BufferedImage bi,
                                       java.lang.String path,
                                       boolean as_grey)

openTIFF

public static final java.awt.image.BufferedImage openTIFF(java.lang.String path,
                                                          boolean ensure_premultiplied_alpha)
Opens RGB or RGB + alpha images stored in TIFF format.


openGreyTIFF

public static final java.awt.image.BufferedImage openGreyTIFF(java.lang.String path)