public class ImageWriter extends java.lang.Object implements IFormatWriter
Modifier and Type | Field and Description |
---|---|
protected java.lang.String[] |
compressionTypes
Compression types for all file format writers.
|
protected int |
current
Current form index.
|
protected java.lang.String |
currentId
Name of current file.
|
private static ClassList<IFormatWriter> |
defaultClasses
Default list of writer classes, for use with noargs constructor.
|
private static org.slf4j.Logger |
LOGGER |
private java.lang.String[] |
suffixes
Valid suffixes for all file format writers.
|
protected IFormatWriter[] |
writers
List of supported file format writers.
|
Constructor and Description |
---|
ImageWriter()
Constructs a new ImageWriter with the default
list of writer classes from writers.txt.
|
ImageWriter(ClassList<IFormatWriter> classList)
Constructs a new ImageWriter from the given list of writer classes.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDoStacks()
Reports whether the writer can save multiple images to a single file.
|
void |
changeOutputFile(java.lang.String id)
Switch the output file for the current dataset.
|
void |
close() |
java.awt.image.ColorModel |
getColorModel()
Gets the color model.
|
java.lang.String |
getCompression()
Gets the current compression type.
|
java.lang.String[] |
getCompressionTypes()
Gets the available compression types.
|
static ClassList<IFormatWriter> |
getDefaultWriterClasses() |
java.lang.String |
getFormat()
Gets the name of this file format.
|
java.lang.String |
getFormat(java.lang.String id)
Gets a string describing the file format for the given file.
|
int |
getFramesPerSecond()
Gets the frames per second to use when writing.
|
MetadataOptions |
getMetadataOptions() |
MetadataRetrieve |
getMetadataRetrieve()
Retrieves the current metadata retrieval object for this writer.
|
java.lang.Class<?> |
getNativeDataType()
Returns the native data type of image planes for this reader, as returned
by
IFormatReader.openPlane(int, int, int, int, int) or IFormatWriter.savePlane(int, java.lang.Object) . |
int[] |
getPixelTypes()
Gets the supported pixel types.
|
int[] |
getPixelTypes(java.lang.String codec)
Gets the supported pixel types for the given codec.
|
int |
getSeries()
Returns the current series.
|
java.lang.String[] |
getSuffixes()
Gets the default file suffixes for this file format.
|
java.util.Set<MetadataLevel> |
getSupportedMetadataLevels() |
int |
getTileSizeX()
Retrieves the current tile width
Defaults to full image width if not supported
|
int |
getTileSizeY()
Retrieves the current tile height
Defaults to full image height if not supported
|
IFormatWriter |
getWriter()
Gets the writer used to save the current file.
|
IFormatWriter |
getWriter(java.lang.Class<? extends IFormatWriter> c)
Gets the file format writer instance matching the given class.
|
IFormatWriter |
getWriter(java.lang.String id)
Gets the writer used to save the given file.
|
IFormatWriter[] |
getWriters()
Gets all constituent file format writers.
|
boolean |
isInterleaved()
Gets whether or not the channels in an image are interleaved.
|
boolean |
isSupportedType(int type)
Checks if the given pixel type is supported.
|
boolean |
isThisType(java.lang.String name)
Checks if the given string is a valid filename for this file format.
|
void |
saveBytes(int no,
byte[] buf)
Saves the given image to the current series in the current file.
|
void |
saveBytes(int no,
byte[] buf,
int x,
int y,
int w,
int h)
Saves the given image tile to the current series in the current file.
|
void |
saveBytes(int no,
byte[] buf,
loci.common.Region tile)
Saves the given image tile to the current series in the current file.
|
void |
savePlane(int no,
java.lang.Object plane)
Saves the given image plane to the current series in the current file.
|
void |
savePlane(int no,
java.lang.Object plane,
int x,
int y,
int w,
int h)
Saves the given image plane to the current series in the current file.
|
void |
savePlane(int no,
java.lang.Object plane,
loci.common.Region tile)
Saves the given image plane to the current series in the current file.
|
void |
setCodecOptions(CodecOptions options)
Sets the codec options.
|
void |
setColorModel(java.awt.image.ColorModel cm)
Sets the color model.
|
void |
setCompression(java.lang.String compress)
Sets the current compression type.
|
void |
setFramesPerSecond(int rate)
Sets the frames per second to use when writing.
|
void |
setId(java.lang.String id)
Sets the current file name.
|
void |
setInterleaved(boolean interleaved)
Sets whether or not the channels in an image are interleaved.
|
void |
setMetadataOptions(MetadataOptions options) |
void |
setMetadataRetrieve(MetadataRetrieve r)
Sets the metadata retrieval object from
which to retrieve standardized metadata.
|
void |
setSeries(int series)
Sets the current series.
|
int |
setTileSizeX(int tileSize)
Will attempt to set the tile width to the desired value and return the actual value which will be used
|
int |
setTileSizeY(int tileSize)
Will attempt to set the tile height to the desired value and return the actual value which will be used
|
void |
setValidBitsPerPixel(int bits)
Sets the number of valid bits per pixel.
|
void |
setWriteSequentially(boolean sequential)
Sets whether or not we know that planes will be written sequentially.
|
private static final org.slf4j.Logger LOGGER
private static ClassList<IFormatWriter> defaultClasses
protected IFormatWriter[] writers
private java.lang.String[] suffixes
protected java.lang.String[] compressionTypes
protected java.lang.String currentId
protected int current
public ImageWriter()
public ImageWriter(ClassList<IFormatWriter> classList)
public static ClassList<IFormatWriter> getDefaultWriterClasses()
public java.lang.String getFormat(java.lang.String id) throws FormatException, java.io.IOException
FormatException
java.io.IOException
public IFormatWriter getWriter(java.lang.String id) throws FormatException
FormatException
public IFormatWriter getWriter()
public IFormatWriter getWriter(java.lang.Class<? extends IFormatWriter> c)
public IFormatWriter[] getWriters()
public int getTileSizeX() throws FormatException
IFormatWriter
getTileSizeX
in interface IFormatWriter
FormatException
- Image metadata including Pixels Size X must be set prior to calling getTileSizeX()public int setTileSizeX(int tileSize) throws FormatException
IFormatWriter
setTileSizeX
in interface IFormatWriter
tileSize
- The tile width you wish to useFormatException
- Tile size must be greater than 0 and less than the image widthpublic int getTileSizeY() throws FormatException
IFormatWriter
getTileSizeY
in interface IFormatWriter
FormatException
- Image metadata including Pixels Size Y must be set prior to calling getTileSizeY()public int setTileSizeY(int tileSize) throws FormatException
IFormatWriter
setTileSizeY
in interface IFormatWriter
tileSize
- The tile height you wish to useFormatException
- Tile size must be greater than 0 and less than the image heightpublic java.util.Set<MetadataLevel> getSupportedMetadataLevels()
getSupportedMetadataLevels
in interface IMetadataConfigurable
public MetadataOptions getMetadataOptions()
getMetadataOptions
in interface IMetadataConfigurable
public void setMetadataOptions(MetadataOptions options)
setMetadataOptions
in interface IMetadataConfigurable
IMetadataConfigurable.setMetadataOptions(MetadataOptions)
public void changeOutputFile(java.lang.String id) throws FormatException, java.io.IOException
IFormatWriter
changeOutputFile
in interface IFormatWriter
FormatException
java.io.IOException
public void saveBytes(int no, byte[] buf) throws FormatException, java.io.IOException
IFormatWriter
saveBytes
in interface IFormatWriter
no
- the image index within the current file, starting from 0.buf
- the byte array that represents the image.FormatException
- if one of the parameters is invalid.java.io.IOException
- if there was a problem writing to the file.public void saveBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, java.io.IOException
IFormatWriter
saveBytes
in interface IFormatWriter
no
- the image index within the current file, starting from 0.buf
- the byte array that represents the image tile.x
- the X coordinate of the upper-left corner of the image tile.y
- the Y coordinate of the upper-left corner of the image tile.w
- the width (in pixels) of the image tile.h
- the height (in pixels) of the image tile.FormatException
- if one of the parameters is invalid.java.io.IOException
- if there was a problem writing to the file.public void saveBytes(int no, byte[] buf, loci.common.Region tile) throws FormatException, java.io.IOException
IFormatWriter
saveBytes
in interface IFormatWriter
no
- the image index within the current file, starting from 0.buf
- the byte array that represents the image tile.tile
- the Region representing the image tile to be read.FormatException
- if one of the parameters is invalid.java.io.IOException
- if there was a problem writing to the file.public void savePlane(int no, java.lang.Object plane) throws FormatException, java.io.IOException
IFormatWriter
savePlane
in interface IFormatWriter
no
- the image index within the current file, starting from 0.plane
- the image plane.FormatException
- if one of the parameters is invalid.java.io.IOException
- if there was a problem writing to the file.public void savePlane(int no, java.lang.Object plane, int x, int y, int w, int h) throws FormatException, java.io.IOException
IFormatWriter
savePlane
in interface IFormatWriter
no
- the image index within the current file, starting from 0.plane
- the image plane.x
- the X coordinate of the upper-left corner of the image tile.y
- the Y coordinate of the upper-left corner of the image tile.w
- the width (in pixels) of the image tile.h
- the height (in pixels) of the image tile.FormatException
- if one of the parameters is invalid.java.io.IOException
- if there was a problem writing to the file.public void savePlane(int no, java.lang.Object plane, loci.common.Region tile) throws FormatException, java.io.IOException
IFormatWriter
savePlane
in interface IFormatWriter
no
- the image index within the current file, starting from 0.plane
- the image plane.tile
- the Region representing the image tile to be read.FormatException
- if one of the parameters is invalid.java.io.IOException
- if there was a problem writing to the file.public void setSeries(int series) throws FormatException
IFormatWriter
setSeries
in interface IFormatWriter
series
- the series index, starting from 0.FormatException
- if the specified series is invalid.public int getSeries()
IFormatWriter
getSeries
in interface IFormatWriter
public void setInterleaved(boolean interleaved)
IFormatWriter
setInterleaved
in interface IFormatWriter
public boolean isInterleaved()
IFormatWriter
isInterleaved
in interface IFormatWriter
public void setValidBitsPerPixel(int bits)
IFormatWriter
setValidBitsPerPixel
in interface IFormatWriter
public boolean canDoStacks()
IFormatWriter
canDoStacks
in interface IFormatWriter
public void setMetadataRetrieve(MetadataRetrieve r)
IFormatWriter
setMetadataRetrieve
in interface IFormatWriter
public MetadataRetrieve getMetadataRetrieve()
IFormatWriter
null
metadata retrieval object.getMetadataRetrieve
in interface IFormatWriter
public void setColorModel(java.awt.image.ColorModel cm)
IFormatWriter
setColorModel
in interface IFormatWriter
public java.awt.image.ColorModel getColorModel()
IFormatWriter
getColorModel
in interface IFormatWriter
public void setFramesPerSecond(int rate)
IFormatWriter
setFramesPerSecond
in interface IFormatWriter
public int getFramesPerSecond()
IFormatWriter
getFramesPerSecond
in interface IFormatWriter
public java.lang.String[] getCompressionTypes()
IFormatWriter
getCompressionTypes
in interface IFormatWriter
public int[] getPixelTypes()
IFormatWriter
getPixelTypes
in interface IFormatWriter
public int[] getPixelTypes(java.lang.String codec)
IFormatWriter
getPixelTypes
in interface IFormatWriter
public boolean isSupportedType(int type)
IFormatWriter
isSupportedType
in interface IFormatWriter
public void setCompression(java.lang.String compress) throws FormatException
IFormatWriter
setCompression
in interface IFormatWriter
FormatException
public java.lang.String getCompression()
IFormatWriter
getCompression
in interface IFormatWriter
public void setWriteSequentially(boolean sequential)
IFormatWriter
setWriteSequentially
in interface IFormatWriter
public void setCodecOptions(CodecOptions options)
IFormatWriter
setCodecOptions
in interface IFormatWriter
options
- The options to set.public boolean isThisType(java.lang.String name)
IFormatHandler
isThisType
in interface IFormatHandler
public java.lang.String getFormat()
IFormatHandler
getFormat
in interface IFormatHandler
public java.lang.String[] getSuffixes()
IFormatHandler
getSuffixes
in interface IFormatHandler
public java.lang.Class<?> getNativeDataType()
IFormatHandler
IFormatReader.openPlane(int, int, int, int, int)
or IFormatWriter.savePlane(int, java.lang.Object)
.
For most readers this type will be a byte array; however, some readers
call external APIs that work with other types such as
BufferedImage
.getNativeDataType
in interface IFormatHandler
public void setId(java.lang.String id) throws FormatException, java.io.IOException
IFormatHandler
setId
in interface IFormatHandler
FormatException
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
Copyright © 2017 Open Microscopy Environment