From 079dc54c945f12380b7b935a0765dba76fac257f Mon Sep 17 00:00:00 2001 From: cc Date: Wed, 20 Aug 2025 17:47:38 -0700 Subject: Read Entire TIFF data --- src/tiff.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/tiff.rs') diff --git a/src/tiff.rs b/src/tiff.rs index 08f4d54..8e77233 100644 --- a/src/tiff.rs +++ b/src/tiff.rs @@ -97,3 +97,19 @@ pub fn read_strip(tiff_ptr: *mut TIFF, strip: u32) -> Vec { } buf } + +pub fn read(tiff_ptr: *mut TIFF) -> Vec { + let strip_size = get_strip_size(tiff_ptr); + let strip_count = get_strip_count(tiff_ptr); + let mut total_buf: Vec = vec![0u8; (strip_size * strip_count) as usize]; + for strip_index in 0..strip_count { + let sub_buffer: Vec = read_strip(tiff_ptr, strip_index as u32); + let base_index = strip_index * strip_size; + for data_index in 0..strip_size { + let total_index = base_index + data_index; + let data = sub_buffer[data_index as usize]; + total_buf[total_index as usize] = data; + } + } + total_buf +} -- cgit v1.2.1