Package gov.nih.mipav.model.algorithms
Class ContourPlot.ImageSaver
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.ContourPlot.ImageSaver
-
- Enclosing class:
- ContourPlot
public static class ContourPlot.ImageSaver extends java.lang.Object
Class providing convenience methods for saving Images to file.- Since:
- 1.0
- Author:
- hageldave
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ContourPlot.ImageSaver.ImageSaverException
RuntimeException class for Exceptions that occur during image saving.
-
Constructor Summary
Constructors Modifier Constructor Description private
ImageSaver()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String[]
getSaveableImageFileFormats()
private static boolean
isBufferedImageOfType(java.awt.Image image, int type)
static boolean
isFormatBWOnly(java.lang.String imgFormat)
static boolean
isFormatRGBOnly(java.lang.String imgFormat)
returns if specified image format supports rgb values only.static void
saveImage(java.awt.Image image, java.io.File file)
Saves Image usingsaveImage(Image, File, String)
.static void
saveImage(java.awt.Image image, java.io.File file, java.lang.String imgFileFormat)
Saves image usingsaveImage(Image, OutputStream, String)
.static void
saveImage(java.awt.Image image, java.io.OutputStream os, java.lang.String imgFileFormat)
Saves specified Image to file of specified img file format.static void
saveImage(java.awt.Image image, java.lang.String filename)
Saves Image usingsaveImage(Image, File)
.static void
saveImage(java.awt.Image image, java.lang.String filename, java.lang.String imgFileFormat)
Saves image usingsaveImage(Image, File, String)
.
-
-
-
Method Detail
-
getSaveableImageFileFormats
public static java.lang.String[] getSaveableImageFileFormats()
- Returns:
ImageIO.getWriterFileSuffixes()
- Since:
- 1.0
-
isFormatRGBOnly
public static boolean isFormatRGBOnly(java.lang.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(java.lang.String imgFormat)
-
saveImage
public static void saveImage(java.awt.Image image, java.io.OutputStream os, java.lang.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 savedos
-OutputStream
to write image to.imgFileFormat
- image file format. ConsultgetSaveableImageFileFormats()
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(java.awt.Image image, int type)
-
saveImage
public static void saveImage(java.awt.Image image, java.lang.String filename, java.lang.String imgFileFormat)
Saves image usingsaveImage(Image, File, String)
.- Parameters:
image
- to be savedfilename
- path to fileimgFileFormat
- image file format. ConsultgetSaveableImageFileFormats()
- 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(java.awt.Image image, java.io.File file, java.lang.String imgFileFormat)
Saves image usingsaveImage(Image, OutputStream, String)
.- Parameters:
image
- to be savedfile
- to save image toimgFileFormat
- image file format. ConsultgetSaveableImageFileFormats()
- 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(java.awt.Image image, java.io.File file)
Saves Image usingsaveImage(Image, File, String)
. The file format is extracted from the files name.- Parameters:
image
- to be savedfile
- 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(java.awt.Image image, java.lang.String filename)
Saves Image usingsaveImage(Image, File)
. The file format is extracted from the files name.- Parameters:
image
- to be savedfilename
- 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
-
-