From 738dea9987b3def65b76506513246d544502e6f1 Mon Sep 17 00:00:00 2001 From: Wim Pomp Date: Mon, 23 Dec 2024 18:55:24 +0100 Subject: [PATCH] - bugfix: height and width were swapped - include checksum in zstd otherwise Fiji cannot some very specific frames --- Cargo.toml | 2 +- src/lib.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2525287..526d0ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tiffwrite" -version = "2024.12.0" +version = "2024.12.1" edition = "2021" authors = ["Wim Pomp "] license = "GPL-3.0-or-later" diff --git a/src/lib.rs b/src/lib.rs index 9a1c4cb..90f2539 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -473,8 +473,8 @@ impl CompressedFrame { CompressedFrame { bytes, - image_width: shape[0] as u32, - image_length: shape[1] as u32, + image_width: shape[1] as u32, + image_length: shape[0] as u32, tile_width, tile_length, bits_per_sample: T::BITS_PER_SAMPLE, @@ -507,6 +507,7 @@ impl CompressedFrame { let bytes_per_sample = (T::BITS_PER_SAMPLE / 8) as usize; encoder.include_contentsize(true)?; encoder.set_pledged_src_size(Some((bytes_per_sample * tile_width * tile_length) as u64))?; + encoder.include_checksum(true)?; let shape = (slice.1 - slice.0, slice.3 - slice.2); for i in 0..shape.0 { CompressedFrame::write( @@ -572,6 +573,7 @@ impl Frame { /// trait to convert numbers to bytes pub trait Bytes { const BITS_PER_SAMPLE: u16; + /// 1: unsigned int, 2: signed int, 3: float const SAMPLE_FORMAT: u16; fn bytes(&self) -> Vec; @@ -612,11 +614,13 @@ bytes_impl!(isize, 32, 2); bytes_impl!(f32, 32, 3); bytes_impl!(f64, 64, 3); -/// what colormap to save in the tiff; None, Colors: gradient from black to color, or full Colormap +/// what colormap to save in the tiff; #[derive(Clone, Debug)] pub enum Colors { None, + /// gradient from black to rgb color, 1 vec per channel Colors(Vec>), + /// vec of rgb colors Colormap(Vec>), }