Class ContourPlot.ImageSaver

java.lang.Object
gov.nih.mipav.model.algorithms.ContourPlot.ImageSaver
Enclosing class:
ContourPlot

public static class ContourPlot.ImageSaver extends Object
Class providing convenience methods for saving Images to file.
Since:
1.0
Author:
hageldave
  • Constructor Details

    • ImageSaver

      private ImageSaver()
  • Method Details

    • getSaveableImageFileFormats

      public static String[] getSaveableImageFileFormats()
      Returns:
      ImageIO.getWriterFileSuffixes()
      Since:
      1.0
    • isFormatRGBOnly

      public static boolean isFormatRGBOnly(String imgFormat)
      returns if specified image format supports rgb values only. This means argb values probably need conversion beforehand.
      Parameters:
      imgFormat - the file format e.g. jpg or png
      Returns:
      true if format only supports rgb values
      Since:
      1.0
    • isFormatBWOnly

      public static boolean isFormatBWOnly(String imgFormat)
    • saveImage

      public static void saveImage(Image image, OutputStream os, String imgFileFormat)
      Saves specified Image to file of specified img file format.

      Some image file formats may require image type conversion before saving. This method converts to type INT_RGB for jpg, jpeg and bmp, and to type BYTE_BINARY for wbmp.

      The provided OutputStream will not be closed, this is the responsibility of the caller.

      Parameters:
      image - to be saved
      os - OutputStream to write image to.
      imgFileFormat - image file format. Consult getSaveableImageFileFormats() to get the supported img file formats of your system.
      Throws:
      ContourPlot.ImageSaver.ImageSaverException - if an IOException occurred during the process or no appropriate writer could be found for specified format.
      Since:
      1.1
    • isBufferedImageOfType

      private static final boolean isBufferedImageOfType(Image image, int type)
    • saveImage

      public static void saveImage(Image image, String filename, String imgFileFormat)
      Parameters:
      image - to be saved
      filename - path to file
      imgFileFormat - image file format. Consult getSaveableImageFileFormats()
      Throws:
      ContourPlot.ImageSaver.ImageSaverException - if an IOException occurred during the process, the provided filename path does refer to a directory or no appropriate writer could be found for specified format.
      Since:
      1.0
    • saveImage

      public static void saveImage(Image image, File file, String imgFileFormat)
      Parameters:
      image - to be saved
      file - to save image to
      imgFileFormat - image file format. Consult getSaveableImageFileFormats()
      Throws:
      ContourPlot.ImageSaver.ImageSaverException - if an IOException occurred during the process, no OutputStream could be created due to a FileNotFoundException or no appropriate writer could be found for specified format.
      Since:
      1.0
    • saveImage

      public static void saveImage(Image image, File file)
      Saves Image using saveImage(Image, File, String). The file format is extracted from the files name.
      Parameters:
      image - to be saved
      file - to save image to
      Throws:
      ContourPlot.ImageSaver.ImageSaverException - if an IOException occurred during the process, the filename does not contain a dot to get the filetype or no appropriate writer could be found for specified format.
      Since:
      1.0
    • saveImage

      public static void saveImage(Image image, String filename)
      Saves Image using saveImage(Image, File). The file format is extracted from the files name.
      Parameters:
      image - to be saved
      filename - path to file to save image to
      Throws:
      ContourPlot.ImageSaver.ImageSaverException - if an IOException occurred during the process, the filename does not contain a dot to get the filetype, the provided filename path does refer to a directory, or no appropriate writer could be found for specified format.
      Since:
      1.0