public abstract class WriterWrapper extends Object implements IFormatWriter
Modifier and Type | Field and Description |
---|---|
protected IFormatWriter |
writer
FormatWriter used to write the file.
|
Constructor and Description |
---|
WriterWrapper()
Constructs a writer wrapper around a new image writer.
|
WriterWrapper(IFormatWriter w)
Constructs a writer wrapper around the given writer.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDoStacks()
Reports whether the writer can save multiple images to a single file.
|
void |
changeOutputFile(String id)
Switch the output file for the current dataset.
|
void |
close() |
WriterWrapper |
duplicate(Class<? extends IFormatWriter> imageWriterClass)
Performs a deep copy of the writer, including nested wrapped writers.
|
ColorModel |
getColorModel()
Gets the color model.
|
String |
getCompression()
Gets the current compression type.
|
String[] |
getCompressionTypes()
Gets the available compression types.
|
String |
getFormat()
Gets the name of this file format.
|
int |
getFramesPerSecond()
Gets the frames per second to use when writing.
|
MetadataRetrieve |
getMetadataRetrieve()
Retrieves the current metadata retrieval object for this writer.
|
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(String codec)
Gets the supported pixel types for the given codec.
|
int |
getSeries()
Returns the current series.
|
String[] |
getSuffixes()
Gets the default file suffixes for this file format.
|
IFormatWriter |
getWriter()
Gets the wrapped writer.
|
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(String name)
Checks if the given string is a valid filename for this file format.
|
void |
saveBytes(byte[] bytes,
boolean last)
Deprecated.
|
void |
saveBytes(byte[] bytes,
int series,
boolean lastInSeries,
boolean last)
Deprecated.
|
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,
Region tile)
Saves the given image tile to the current series in the current file.
|
void |
savePlane(int no,
Object plane)
Saves the given image plane to the current series in the current file.
|
void |
savePlane(int no,
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,
Object plane,
Region tile)
Saves the given image plane to the current series in the current file.
|
void |
savePlane(Object plane,
boolean last)
Deprecated.
|
void |
savePlane(Object plane,
int series,
boolean lastInSeries,
boolean last)
Deprecated.
|
void |
setCodecOptions(CodecOptions options)
Sets the codec options.
|
void |
setColorModel(ColorModel cm)
Sets the color model.
|
void |
setCompression(String compress)
Sets the current compression type.
|
void |
setFramesPerSecond(int rate)
Sets the frames per second to use when writing.
|
void |
setId(String id)
Sets the current file name.
|
void |
setInterleaved(boolean interleaved)
Sets whether or not the channels in an image are interleaved.
|
void |
setMetadataRetrieve(MetadataRetrieve r)
Sets the metadata retrieval object from
which to retrieve standardized metadata.
|
void |
setSeries(int series)
Sets the current series.
|
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.
|
IFormatWriter |
unwrap()
Unwraps nested wrapped writers until the core writer (i.e., not
a
WriterWrapper or ImageWriter ) is found. |
IFormatWriter |
unwrap(Class<? extends IFormatWriter> writerClass,
String id)
Unwraps nested wrapped writers until the given writer class is found.
|
IFormatWriter |
unwrap(String id)
Unwraps nested wrapped writers until the core writer (i.e., not
a
WriterWrapper or ImageWriter ) is found. |
protected IFormatWriter writer
public WriterWrapper()
public WriterWrapper(IFormatWriter w)
public IFormatWriter getWriter()
public IFormatWriter unwrap() throws FormatException, IOException
WriterWrapper
or ImageWriter
) is found.FormatException
IOException
public IFormatWriter unwrap(String id) throws FormatException, IOException
WriterWrapper
or ImageWriter
) is found.id
- Id to use as a basis when unwrapping any nested
ImageWriter
s. If null, the current id is used.FormatException
IOException
public IFormatWriter unwrap(Class<? extends IFormatWriter> writerClass, String id) throws FormatException, IOException
writerClass
- Class of the desired nested writer. If null, the
core writer (i.e., deepest wrapped writer) will be returned.id
- Id to use as a basis when unwrapping any nested
ImageWriter
s. If null, the current id is used.FormatException
IOException
public WriterWrapper duplicate(Class<? extends IFormatWriter> imageWriterClass) throws FormatException
imageWriterClass
- If non-null, any ImageWriter
s in the
writer stack will be replaced with instances of the given class.FormatException
- If something goes wrong during the duplication.public void changeOutputFile(String id) throws FormatException, IOException
IFormatWriter
changeOutputFile
in interface IFormatWriter
FormatException
IOException
public void saveBytes(int no, byte[] buf) throws FormatException, 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.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, 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.IOException
- if there was a problem writing to the file.public void saveBytes(int no, byte[] buf, Region tile) throws FormatException, 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.IOException
- if there was a problem writing to the file.public void savePlane(int no, Object plane) throws FormatException, 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.IOException
- if there was a problem writing to the file.public void savePlane(int no, Object plane, int x, int y, int w, int h) throws FormatException, 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.IOException
- if there was a problem writing to the file.public void savePlane(int no, Object plane, Region tile) throws FormatException, 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.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(ColorModel cm)
IFormatWriter
setColorModel
in interface IFormatWriter
public 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 String[] getCompressionTypes()
IFormatWriter
getCompressionTypes
in interface IFormatWriter
public int[] getPixelTypes()
IFormatWriter
getPixelTypes
in interface IFormatWriter
public int[] getPixelTypes(String codec)
IFormatWriter
getPixelTypes
in interface IFormatWriter
public boolean isSupportedType(int type)
IFormatWriter
isSupportedType
in interface IFormatWriter
public void setCompression(String compress) throws FormatException
IFormatWriter
setCompression
in interface IFormatWriter
FormatException
public void setCodecOptions(CodecOptions options)
IFormatWriter
setCodecOptions
in interface IFormatWriter
options
- The options to set.public String getCompression()
IFormatWriter
getCompression
in interface IFormatWriter
public void setWriteSequentially(boolean sequential)
IFormatWriter
setWriteSequentially
in interface IFormatWriter
public void saveBytes(byte[] bytes, boolean last) throws FormatException, IOException
saveBytes
in interface IFormatWriter
FormatException
IOException
public void saveBytes(byte[] bytes, int series, boolean lastInSeries, boolean last) throws FormatException, IOException
saveBytes
in interface IFormatWriter
FormatException
IOException
public void savePlane(Object plane, boolean last) throws FormatException, IOException
savePlane
in interface IFormatWriter
FormatException
IOException
public void savePlane(Object plane, int series, boolean lastInSeries, boolean last) throws FormatException, IOException
savePlane
in interface IFormatWriter
FormatException
IOException
public boolean isThisType(String name)
IFormatHandler
isThisType
in interface IFormatHandler
public String getFormat()
IFormatHandler
getFormat
in interface IFormatHandler
public String[] getSuffixes()
IFormatHandler
getSuffixes
in interface IFormatHandler
public 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(String id) throws FormatException, IOException
IFormatHandler
setId
in interface IFormatHandler
FormatException
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2014 Open Microscopy Environment