diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 11 | ||||
-rw-r--r-- | src/tiff.rs | 16 |
2 files changed, 27 insertions, 0 deletions
@@ -94,6 +94,17 @@ mod tests { } #[test] + fn tiff_read() { + tiff::ignore_warnings(); + if let Some(t_handle) = tiff::open("../test.tif") { + let data = tiff::read(t_handle); + tiff::close(t_handle); + } else { + assert!(false); + } + } + + #[test] fn tiff_strip_read() { tiff::ignore_warnings(); if let Some(t_handle) = tiff::open("../test.tif") { 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<u8> { } buf } + +pub fn read(tiff_ptr: *mut TIFF) -> Vec<u8> { + let strip_size = get_strip_size(tiff_ptr); + let strip_count = get_strip_count(tiff_ptr); + let mut total_buf: Vec<u8> = vec![0u8; (strip_size * strip_count) as usize]; + for strip_index in 0..strip_count { + let sub_buffer: Vec<u8> = 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 +} |