public class TiffSaver extends Object
Modifier and Type | Field and Description |
---|---|
private boolean |
bigTiff
Whether or not to write BigTIFF data.
|
protected ByteArrayHandle |
bytes
Output bytes.
|
protected String |
filename
Output filename.
|
private static org.slf4j.Logger |
LOGGER |
private CodecOptions |
options
The codec options if set.
|
protected RandomAccessOutputStream |
out
Output stream to use when saving TIFF data.
|
private boolean |
sequentialWrite |
Constructor and Description |
---|
TiffSaver(RandomAccessOutputStream out,
ByteArrayHandle bytes)
Constructs a new TIFF saver from the given output source.
|
TiffSaver(RandomAccessOutputStream out,
String filename)
Constructs a new TIFF saver from the given output source.
|
TiffSaver(String filename)
Constructs a new TIFF saver from the given filename.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the output stream if not null.
|
RandomAccessOutputStream |
getStream()
Gets the stream from which TIFF data is being saved.
|
boolean |
isBigTiff()
Returns whether or not we are writing BigTIFF data.
|
boolean |
isLittleEndian()
Returns whether or not we are writing little-endian data.
|
private void |
makeValidIFD(IFD ifd,
int pixelType,
int nChannels)
Makes a valid IFD.
|
void |
overwriteComment(RandomAccessInputStream in,
Object value)
Convenience method for overwriting a file's first ImageDescription.
|
void |
overwriteIFDValue(RandomAccessInputStream raf,
int ifd,
int tag,
Object value)
Surgically overwrites an existing IFD value with the given one.
|
void |
overwriteLastIFDOffset(RandomAccessInputStream raf) |
void |
setBigTiff(boolean bigTiff)
Sets whether or not BigTIFF data should be written.
|
void |
setCodecOptions(CodecOptions options)
Sets the codec options.
|
void |
setLittleEndian(boolean littleEndian)
Sets whether or not little-endian data should be written.
|
void |
setWritingSequentially(boolean sequential)
Sets whether or not we know that the planes will be written sequentially.
|
private long[] |
toPrimitiveArray(List<Long> l)
Coverts a list to a primitive array.
|
void |
writeHeader()
Writes the TIFF file header.
|
void |
writeIFD(IFD ifd,
long nextOffset) |
void |
writeIFDValue(RandomAccessOutputStream extraOut,
long offset,
int tag,
Object value)
Writes the given IFD value to the given output object.
|
void |
writeImage(byte[][] buf,
IFDList ifds,
int pixelType) |
void |
writeImage(byte[] buf,
IFD ifd,
int no,
int pixelType,
boolean last) |
void |
writeImage(byte[] buf,
IFD ifd,
int no,
int pixelType,
int x,
int y,
int w,
int h,
boolean last)
Writes to any rectangle from the passed block.
|
void |
writeImage(byte[] buf,
IFD ifd,
int no,
int pixelType,
int x,
int y,
int w,
int h,
boolean last,
Integer nChannels,
boolean copyDirectly) |
private void |
writeImageIFD(IFD ifd,
int no,
byte[][] strips,
int nChannels,
boolean last,
int x,
int y)
Performs the actual work of dealing with IFD data and writing it to the
TIFF for a given image or sub-image.
|
private void |
writeIntValue(RandomAccessOutputStream out,
long offset)
Write the given value to the given RandomAccessOutputStream.
|
private static final org.slf4j.Logger LOGGER
protected RandomAccessOutputStream out
protected String filename
protected ByteArrayHandle bytes
private boolean bigTiff
private boolean sequentialWrite
private CodecOptions options
public TiffSaver(String filename) throws IOException
filename
- Filename of the output stream that we may use to create
extra input or output streams as required.IOException
public TiffSaver(RandomAccessOutputStream out, String filename)
out
- Output stream to save TIFF data to.filename
- Filename of the output stream that we may use to create
extra input or output streams as required.public TiffSaver(RandomAccessOutputStream out, ByteArrayHandle bytes)
out
- Output stream to save TIFF data to.bytes
- In memory byte array handle that we may use to create
extra input or output streams as required.public void close() throws IOException
IOException
- Thrown if an error occurred while closing.public void setWritingSequentially(boolean sequential)
public RandomAccessOutputStream getStream()
public void setLittleEndian(boolean littleEndian)
public void setBigTiff(boolean bigTiff)
public boolean isLittleEndian()
public boolean isBigTiff()
public void setCodecOptions(CodecOptions options)
options
- The value to set.public void writeHeader() throws IOException
IOException
public void writeImage(byte[][] buf, IFDList ifds, int pixelType) throws FormatException, IOException
FormatException
IOException
public void writeImage(byte[] buf, IFD ifd, int no, int pixelType, boolean last) throws FormatException, IOException
FormatException
IOException
public void writeImage(byte[] buf, IFD ifd, int no, int pixelType, int x, int y, int w, int h, boolean last) throws FormatException, IOException
buf
- The block that is to be written.ifd
- The Image File Directories. Mustn't be null
.no
- The image index within the current file, starting from 0.pixelType
- The type of pixels.x
- The X-coordinate of the top-left corner.y
- The Y-coordinate of the top-left corner.w
- The width of the rectangle.h
- The height of the rectangle.last
- Pass true
if it is the last image,
false
otherwise.FormatException
IOException
public void writeImage(byte[] buf, IFD ifd, int no, int pixelType, int x, int y, int w, int h, boolean last, Integer nChannels, boolean copyDirectly) throws FormatException, IOException
FormatException
IOException
private void writeImageIFD(IFD ifd, int no, byte[][] strips, int nChannels, boolean last, int x, int y) throws FormatException, IOException
ifd
- The Image File Directories. Mustn't be null
.no
- The image index within the current file, starting from 0.strips
- The strips to write to the file.last
- Pass true
if it is the last image,
false
otherwise.x
- The initial X offset of the strips/tiles to write.y
- The initial Y offset of the strips/tiles to write.FormatException
IOException
public void writeIFD(IFD ifd, long nextOffset) throws FormatException, IOException
FormatException
IOException
public void writeIFDValue(RandomAccessOutputStream extraOut, long offset, int tag, Object value) throws FormatException, IOException
extraOut
- buffer to which "extra" IFD information should be writtenoffset
- global offset to use for IFD offset valuestag
- IFD tag to writevalue
- IFD value to writeFormatException
IOException
public void overwriteLastIFDOffset(RandomAccessInputStream raf) throws FormatException, IOException
FormatException
IOException
public void overwriteIFDValue(RandomAccessInputStream raf, int ifd, int tag, Object value) throws FormatException, IOException
FormatException
IOException
public void overwriteComment(RandomAccessInputStream in, Object value) throws FormatException, IOException
FormatException
IOException
private long[] toPrimitiveArray(List<Long> l)
l
- The list of Long
to convert.long[]
with the values from
l.private void writeIntValue(RandomAccessOutputStream out, long offset) throws IOException
IOException
private void makeValidIFD(IFD ifd, int pixelType, int nChannels)
ifd
- The IFD to handle.pixelType
- The pixel type.nChannels
- The number of channels.Copyright © 2016 Open Microscopy Environment