public abstract class FormatWriter extends FormatHandler implements IFormatWriter
Modifier and Type | Field and Description |
---|---|
protected ColorModel |
cm
Default color model.
|
protected String |
compression
Current compression type.
|
protected String[] |
compressionTypes
Available compression types.
|
protected int |
fps
Frame rate to use when writing in frames per second, if applicable.
|
protected boolean[][] |
initialized
Whether each plane in each series of the current file has been
prepped for writing.
|
protected boolean |
interleaved
Whether the channels in an RGB image are interleaved.
|
protected MetadataRetrieve |
metadataRetrieve
Current metadata retrieval object.
|
protected CodecOptions |
options
The options if required.
|
protected RandomAccessOutputStream |
out
Current file.
|
protected boolean |
sequential
Whether or not we are writing planes sequentially.
|
protected int |
series
Current series.
|
protected int |
validBits
The number of valid bits per pixel.
|
COMPRESSION_SUFFIXES, currentId, format, LOGGER, metadataOptions, suffixes
Constructor and Description |
---|
FormatWriter(String format,
String suffix)
Constructs a format writer with the given name and default suffix.
|
FormatWriter(String format,
String[] suffixes)
Constructs a format writer with the given name and default suffixes.
|
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.
|
protected void |
checkParams(int no,
byte[] buf,
int x,
int y,
int w,
int h)
Ensure that the arguments that are being passed to saveBytes(...) are
valid.
|
void |
close() |
ColorModel |
getColorModel()
Gets the color model.
|
String |
getCompression()
Gets the current compression type.
|
String[] |
getCompressionTypes()
Gets the available compression types.
|
int |
getFramesPerSecond()
Gets the frames per second to use when writing.
|
MetadataRetrieve |
getMetadataRetrieve()
Retrieves the current metadata retrieval object for this writer.
|
int[] |
getPixelTypes()
Gets the supported pixel types.
|
int[] |
getPixelTypes(String codec)
Gets the supported pixel types for the given codec.
|
protected int |
getPlaneCount()
Retrieve the total number of planes in the current series.
|
protected int |
getPlaneCount(int series)
Retrieve the total number of planes in given series.
|
protected int |
getSamplesPerPixel()
Retrieve the number of samples per pixel for the current series.
|
protected int |
getSamplesPerPixel(int series)
Retrieve the number of samples per pixel for given series.
|
int |
getSeries()
Returns the current series.
|
protected boolean |
isFullPlane(int x,
int y,
int w,
int h)
Returns true if the given rectangle coordinates correspond to a full
image in the given series.
|
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.
|
void |
saveBytes(int no,
byte[] buf)
Saves the given image 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.
|
protected void |
seekToPlaneOffset(long baseOffset,
int x,
int y)
Seek to the given (x, y) coordinate of the image that starts at
the given offset.
|
void |
setCodecOptions(CodecOptions options)
Sets the codec options.
|
void |
setColorModel(ColorModel model)
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)
Initializes a writer from the input file name.
|
void |
setInterleaved(boolean interleaved)
Sets whether or not the channels in an image are interleaved.
|
void |
setMetadataRetrieve(MetadataRetrieve retrieve)
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.
|
checkSuffix, checkSuffix, getFormat, getMetadataOptions, getNativeDataType, getSuffixes, getSupportedMetadataLevels, isThisType, setMetadataOptions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
saveBytes
getFormat, getNativeDataType, getSuffixes, isThisType
getMetadataOptions, getSupportedMetadataLevels, setMetadataOptions
protected int fps
protected ColorModel cm
protected String[] compressionTypes
protected String compression
protected CodecOptions options
protected boolean[][] initialized
protected boolean interleaved
protected int validBits
protected int series
protected boolean sequential
protected MetadataRetrieve metadataRetrieve
getMetadataRetrieve()
prevent "null" access.protected RandomAccessOutputStream out
public FormatWriter(String format, String suffix)
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, 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 retrieve)
IFormatWriter
setMetadataRetrieve
in interface IFormatWriter
public MetadataRetrieve getMetadataRetrieve()
IFormatWriter
null
metadata retrieval object.getMetadataRetrieve
in interface IFormatWriter
public void setColorModel(ColorModel model)
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 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 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 setWriteSequentially(boolean sequential)
IFormatWriter
setWriteSequentially
in interface IFormatWriter
public void setId(String id) throws FormatException, IOException
RandomAccessOutputStream
for the output
file and initializes the metadata for all the series using
setSeries(int)
.setId
in interface IFormatHandler
id
- a String
specifying the path to the fileFormatException
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
protected void checkParams(int no, byte[] buf, int x, int y, int w, int h) throws FormatException
FormatException
- if any of the arguments is invalid.protected void seekToPlaneOffset(long baseOffset, int x, int y) throws IOException
IOException
protected boolean isFullPlane(int x, int y, int w, int h)
protected int getSamplesPerPixel()
protected int getSamplesPerPixel(int series)
protected int getPlaneCount()
protected int getPlaneCount(int series)
Copyright © 2016 Open Microscopy Environment