Skip to main content

EncodePage

Struct EncodePage 

Source
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: bool

Apply 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: bool

Write 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: bool

Emit 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>

Source§

fn clone(&self) -> EncodePage<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for EncodePage<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for EncodePage<'a>

§

impl<'a> RefUnwindSafe for EncodePage<'a>

§

impl<'a> Send for EncodePage<'a>

§

impl<'a> Sync for EncodePage<'a>

§

impl<'a> Unpin for EncodePage<'a>

§

impl<'a> UnsafeUnpin for EncodePage<'a>

§

impl<'a> UnwindSafe for EncodePage<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.