- bugfix: height and width were swapped

- include checksum in zstd otherwise Fiji cannot some very specific frames
This commit is contained in:
Wim Pomp
2024-12-23 18:55:24 +01:00
parent 7fdfb7c9dc
commit 738dea9987
2 changed files with 8 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "tiffwrite" name = "tiffwrite"
version = "2024.12.0" version = "2024.12.1"
edition = "2021" edition = "2021"
authors = ["Wim Pomp <w.pomp@nki.nl>"] authors = ["Wim Pomp <w.pomp@nki.nl>"]
license = "GPL-3.0-or-later" license = "GPL-3.0-or-later"

View File

@@ -473,8 +473,8 @@ impl CompressedFrame {
CompressedFrame { CompressedFrame {
bytes, bytes,
image_width: shape[0] as u32, image_width: shape[1] as u32,
image_length: shape[1] as u32, image_length: shape[0] as u32,
tile_width, tile_width,
tile_length, tile_length,
bits_per_sample: T::BITS_PER_SAMPLE, bits_per_sample: T::BITS_PER_SAMPLE,
@@ -507,6 +507,7 @@ impl CompressedFrame {
let bytes_per_sample = (T::BITS_PER_SAMPLE / 8) as usize; let bytes_per_sample = (T::BITS_PER_SAMPLE / 8) as usize;
encoder.include_contentsize(true)?; encoder.include_contentsize(true)?;
encoder.set_pledged_src_size(Some((bytes_per_sample * tile_width * tile_length) as u64))?; 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); let shape = (slice.1 - slice.0, slice.3 - slice.2);
for i in 0..shape.0 { for i in 0..shape.0 {
CompressedFrame::write( CompressedFrame::write(
@@ -572,6 +573,7 @@ impl Frame {
/// trait to convert numbers to bytes /// trait to convert numbers to bytes
pub trait Bytes { pub trait Bytes {
const BITS_PER_SAMPLE: u16; const BITS_PER_SAMPLE: u16;
/// 1: unsigned int, 2: signed int, 3: float
const SAMPLE_FORMAT: u16; const SAMPLE_FORMAT: u16;
fn bytes(&self) -> Vec<u8>; fn bytes(&self) -> Vec<u8>;
@@ -612,11 +614,13 @@ bytes_impl!(isize, 32, 2);
bytes_impl!(f32, 32, 3); bytes_impl!(f32, 32, 3);
bytes_impl!(f64, 64, 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)] #[derive(Clone, Debug)]
pub enum Colors { pub enum Colors {
None, None,
/// gradient from black to rgb color, 1 vec per channel
Colors(Vec<Vec<u8>>), Colors(Vec<Vec<u8>>),
/// vec of rgb colors
Colormap(Vec<Vec<u8>>), Colormap(Vec<Vec<u8>>),
} }