public final class TiffPixelCodec extends Object
byte[]/short[]/float[]) to and from
the raw byte representation stored in a TIFF strip, applying the file's byte order and, when
requested, Deflate (zlib) compression (TIFF compression code 8).| Modifier and Type | Method and Description |
|---|---|
static Object |
blankTile(PixelType type,
int numPixels)
A zeroed primitive pixel array of
numPixels pixels of the given type. |
static void |
copyRegion(Object src,
int srcW,
int srcX,
int srcY,
Object dst,
int dstW,
int dstX,
int dstY,
int w,
int h)
Copy a
w×h rectangle between two row-major primitive pixel arrays of the same
type, for single-sample-per-pixel (grayscale) data. |
static void |
copyRegion(Object src,
int srcW,
int srcX,
int srcY,
Object dst,
int dstW,
int dstX,
int dstY,
int w,
int h,
int samplesPerPixel)
Copy a
w×h pixel rectangle between two row-major arrays whose pixels each
span samplesPerPixel array elements (1 for grayscale, 3 for interleaved RGB). |
static byte[] |
deflate(byte[] raw)
Deflate (zlib) compression of a raw strip.
|
static Object |
fromRawBytes(byte[] raw,
PixelType type,
ByteOrder order,
int numPixels)
Decode raw bytes (matching
toRawBytes(java.lang.Object, org.micromanager.mmomebigtiff.PixelType, java.nio.ByteOrder)) back to a primitive pixel array. |
static byte[] |
inflate(byte[] compressed,
int rawLength)
Inverse of
deflate(byte[]); rawLength is the known uncompressed size. |
static byte[] |
packBgraToRgb(byte[] bgra,
int numPixels)
Unpack Micro-Manager's native 4-bytes-per-pixel RGB buffer (interleaved BGRA, alpha
unused) into interleaved 3-sample RGB (
byte[numPixels*3], samples ordered R,G,B) as
stored on disk. |
static int |
rawByteCount(PixelType type,
int numPixels)
Raw (uncompressed) byte length of a plane of
numPixels pixels of the given type. |
static byte[] |
toRawBytes(Object pixels,
PixelType type,
ByteOrder order)
Encode a primitive pixel array to raw little/big-endian bytes (no compression).
|
public static int rawByteCount(PixelType type, int numPixels)
numPixels pixels of the given type.public static byte[] toRawBytes(Object pixels, PixelType type, ByteOrder order)
public static Object fromRawBytes(byte[] raw, PixelType type, ByteOrder order, int numPixels)
toRawBytes(java.lang.Object, org.micromanager.mmomebigtiff.PixelType, java.nio.ByteOrder)) back to a primitive pixel array.public static Object blankTile(PixelType type, int numPixels)
numPixels pixels of the given type.public static void copyRegion(Object src, int srcW, int srcX, int srcY, Object dst, int dstW, int dstX, int dstY, int w, int h)
w×h rectangle between two row-major primitive pixel arrays of the same
type, for single-sample-per-pixel (grayscale) data. Rows are copied with
System.arraycopy(java.lang.Object, int, java.lang.Object, int, int); callers ensure the rectangle lies within both arrays.public static void copyRegion(Object src, int srcW, int srcX, int srcY, Object dst, int dstW, int dstX, int dstY, int w, int h, int samplesPerPixel)
w×h pixel rectangle between two row-major arrays whose pixels each
span samplesPerPixel array elements (1 for grayscale, 3 for interleaved RGB). All
widths/offsets are in pixels; the copy scales them by samplesPerPixel.public static byte[] packBgraToRgb(byte[] bgra,
int numPixels)
byte[numPixels*3], samples ordered R,G,B) as
stored on disk. This is the single place the Micro-Manager channel order is encoded; if the
assumption is wrong, only the index mapping below changes.bgra - source of length >= numPixels*4numPixels - number of pixelspublic static byte[] deflate(byte[] raw)
public static byte[] inflate(byte[] compressed,
int rawLength)
deflate(byte[]); rawLength is the known uncompressed size.Copyright © 2026. All rights reserved.