public final class TiledTiffWriter extends Object implements AutoCloseable
tileWidth×tileHeight tiles (TIFF tags 322–325), so a
plane streams in tile-by-tile and readers can fetch a sub-region by touching only the covering
tiles at the requested pyramid level.
Layout: a BigTIFF header, then all plane IFDs (level 0 chained via the next-IFD offset, each
carrying a SubIFDs tag to its reduced-resolution levels), each IFD's out-of-line
TileOffsets/TileByteCounts arrays reserved (zero-filled) up front. Tile pixel
data is then appended to the file as writeTile(int, int, int, int, java.lang.Object) is called, patching the two array slots
for that tile. Because every offset is explicit, tiles for different planes may be written in
any order. Reduced pyramid levels are synthesized from the level-0 tiles by finish(byte[]).
All in-memory buffers are tile-sized, never plane-sized, so memory use is independent of the canvas size.
| Constructor and Description |
|---|
TiledTiffWriter(Path file,
PixelType type,
long canvasWidth,
long canvasHeight,
int tileWidth,
int tileHeight,
int numLevels,
int numPlanes,
Compression compression,
ByteOrder order,
double pixelSizeUm) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
finish(byte[] omeXmlUtf8)
Synthesize pyramid levels from level-0 tiles, embed the OME-XML, and finalize the file.
|
Path |
getFile() |
int |
getNumLevels() |
boolean |
hasTile(int planeIndex,
int level,
int tileCol,
int tileRow)
Whether a tile has been written (its on-disk offset slot is non-zero).
|
long |
levelHeight(int level) |
long |
levelWidth(int level) |
Object |
readRegion(int planeIndex,
int level,
long x,
long y,
int w,
int h)
Read an arbitrary region of a plane/level, gathering only the covering tiles.
|
Object |
readTile(int planeIndex,
int level,
int tileCol,
int tileRow)
Read one tile back into a primitive pixel array of length
tileWidth*tileHeight. |
int |
tileCount(int level) |
int |
tileHeight() |
int |
tilesAcross(int level) |
int |
tilesDown(int level) |
int |
tileWidth() |
void |
writeTile(int planeIndex,
int level,
int tileCol,
int tileRow,
Object tilePixels)
Write one tile of a plane.
|
public TiledTiffWriter(Path file, PixelType type, long canvasWidth, long canvasHeight, int tileWidth, int tileHeight, int numLevels, int numPlanes, Compression compression, ByteOrder order, double pixelSizeUm) throws IOException
IOExceptionpublic Path getFile()
public int getNumLevels()
public int tilesAcross(int level)
public int tilesDown(int level)
public int tileCount(int level)
public long levelWidth(int level)
public long levelHeight(int level)
public int tileWidth()
public int tileHeight()
public void writeTile(int planeIndex,
int level,
int tileCol,
int tileRow,
Object tilePixels)
throws IOException
tileWidth*tileHeight
samples (edge tiles are zero-padded by the caller).planeIndex - level-0 IFD index of the plane (0-based, in file order)level - pyramid level (0 = full resolution)tileCol - tile column at that leveltileRow - tile row at that leveltilePixels - primitive pixel array of length tileWidth*tileHeightIOExceptionpublic boolean hasTile(int planeIndex,
int level,
int tileCol,
int tileRow)
throws IOException
IOExceptionpublic Object readTile(int planeIndex, int level, int tileCol, int tileRow) throws IOException
tileWidth*tileHeight.IOExceptionpublic Object readRegion(int planeIndex, int level, long x, long y, int w, int h) throws IOException
IOExceptionpublic void finish(byte[] omeXmlUtf8)
throws IOException
IOExceptionpublic void close()
close in interface AutoCloseableCopyright © 2026. All rights reserved.