pub struct EncodePage<'a> {
pub width: u32,
pub height: u32,
pub kind: EncodePixelFormat<'a>,
pub compression: TiffCompression,
pub predictor: bool,
pub planar: bool,
pub tiling: Option<(u32, u32)>,
pub bigtiff: bool,
}Expand description
Description of one image page being written.
pixels is row-major, packed (no padding between rows). For
16-bit grayscale pages the bytes are interpreted little-endian
regardless of the stored byte order — the encoder writes II
files and the input bytes are consumed verbatim.
Fields§
§width: u32§height: u32§kind: EncodePixelFormat<'a>§compression: TiffCompression§predictor: boolApply the TIFF 6.0 §14 horizontal-differencing predictor
(Predictor = 2) to the sample data before compression. The
encoder replaces each component with the difference from the
previous pixel of the same component (offset SamplesPerPixel,
per §14’s “subtract red from red, green from green”) and writes
the Predictor tag (317) so the decoder reverses the step. Only
meaningful for the lossless byte-aligned photometrics whose
decode path supports it — Gray8 (8-bit), Gray16Le (16-bit),
Rgb24 (8-bit × 3), and Palette8 (8-bit indices). §14 ties
the predictor to the byte-stream lossless coders (LZW / Deflate,
and the Compression=50000 Zstandard extension per its trace doc
§4); combining it with the bilevel CCITT schemes
(Compression = 2 / 3) or with Bilevel input is rejected
with a precise error.
planar: boolWrite the image in PlanarConfiguration = 2 (separate component
planes) layout per TIFF 6.0 §“PlanarConfiguration” (page 38).
When set, each sample component is stored in its own
full-resolution strip (one strip per plane), and StripOffsets
/ StripByteCounts carry SamplesPerPixel entries ordered
component-0, component-1, … — the spec’s “SamplesPerPixel rows
and StripsPerImage columns” array with StripsPerImage = 1. Only
meaningful for multi-sample formats (Rgb24); §“PlanarConfiguration”
notes the field “is irrelevant” when SamplesPerPixel is 1, so
planar combined with a single-sample format (Gray8 /
Gray16Le / Palette8 / Bilevel) is rejected with a precise
error. The §14 predictor still applies when both flags are set:
§14 says “If PlanarConfiguration is 2 … Differencing works the
same as it does for grayscale data,” so each plane is differenced
independently with an offset of 1 sample.
tiling: Option<(u32, u32)>Write the image in tiled layout (TIFF 6.0 §15) instead of a
single strip. Some((tile_width, tile_height)) divides the image
into a grid of fixed-size tiles, each compressed independently,
and writes the TileWidth / TileLength / TileOffsets /
TileByteCounts fields (tags 322 / 323 / 324 / 325) in place of
the strip fields (§15: “When the tiling fields … are used, they
replace the StripOffsets, StripByteCounts, and RowsPerStrip
fields … Do not use both strip-oriented and tile-oriented
fields in the same TIFF file”). Both dimensions must be a multiple
of 16 per §15’s TileWidth / TileLength requirement. Boundary
tiles are padded out to the tile geometry (§15 “Padding”:
replicating the last column / row so the padded areas compress
well); the decoder displays only the ImageWidth x ImageLength
region and ignores the padding. Tiles are laid out left-to-right
then top-to-bottom (§15 TileOffsets). Supported on the
byte-aligned chunky formats (Gray8 / Gray16Le / Rgb24 /
Palette8) under None / PackBits / LZW / Deflate / Zstd, with or
without the §14 predictor (applied per-tile, matching the
decoder). Tiling
is rejected on Bilevel (sub-byte tile slicing is not implemented
on either side) and on CCITT compression. It composes with
planar = true on Rgb24: one row-major tile grid per component
plane, emitted plane-0 first then plane-1, etc., per §15
TileOffsets (“For PlanarConfiguration = 2, the offsets for the
first component plane are stored first, followed by all the offsets
for the second component plane”).
bigtiff: boolEmit BigTIFF instead of classic TIFF. Classic TIFF is the default
(false); when set, the encoder writes the 16-byte BigTIFF header
(II/MM + magic 43 + offset-bytesize 8 + reserved 0 + 8-byte
first-IFD offset) per the Adobe Pagemaker 6.0 BigTIFF design that
the decoder’s crate::ifd::parse_header / crate::ifd::parse_ifd
already read. Each IFD then uses 20-byte entries (tag:u16 +
type:u16 + count:u64 + value-or-offset:u64) with an 8-byte
next-IFD pointer, the inline-value threshold widens from 4 to 8
bytes, and the LONG offset/byte-count fields (StripOffsets,
StripByteCounts, TileOffsets, TileByteCounts) are written
as LONG8 (type 16) so the on-disk layout is no longer pinned to
the 32-bit u32 ceiling that classic TIFF enforces (the encoder
returns precise Error::Unsupported if the final byte address
exceeds u32::MAX on a classic page; BigTIFF lifts that limit
to the full u64 file-offset range). The pixel / IFD-entry
semantics are otherwise identical to classic TIFF — all the
pixel formats, compressors, predictor / planar / tiling flags
compose with bigtiff = true unchanged.
For encode_tiff_multi, every page must agree on the variant
(all classic or all BigTIFF); mixing is rejected with a precise
error.
Trait Implementations§
Source§impl<'a> Clone for EncodePage<'a>
impl<'a> Clone for EncodePage<'a>
Source§fn clone(&self) -> EncodePage<'a>
fn clone(&self) -> EncodePage<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more