summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs49
-rw-r--r--src/tiff.rs14
2 files changed, 63 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 9b726c8..9c2033d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -50,4 +50,53 @@ mod tests {
assert!(false);
}
}
+
+ #[test]
+ fn tiff_strip_count() {
+ tiff::ignore_warnings();
+ if let Some(t_handle) = tiff::open("../test.tif") {
+ let strip_count = tiff::get_strip_count(t_handle);
+ assert!(strip_count > 0);
+ println!("{:?}", strip_count);
+ tiff::close(t_handle);
+ } else {
+ assert!(false);
+ }
+ }
+
+ #[test]
+ fn tiff_data_depth() {
+ tiff::ignore_warnings();
+ if let Some(t_handle) = tiff::open("../test.tif") {
+ let strip_size = tiff::get_strip_size(t_handle);
+ let strip_count = tiff::get_strip_count(t_handle);
+ let strip_depth = strip_size * strip_count;
+ assert!(strip_depth > 0);
+ println!("{:?}", strip_depth);
+ let image_width = tiff::get_width(t_handle);
+ let image_height = tiff::get_height(t_handle);
+ let image_depth = image_width * image_height;
+ assert!(image_depth > 0);
+ println!("{:?}", image_depth);
+ let strip_depth = strip_depth as f64;
+ let image_depth = image_depth as f64;
+ println!("{:?}", strip_depth / image_depth);
+ tiff::close(t_handle);
+ } else {
+ assert!(false);
+ }
+ }
+
+ #[test]
+ fn tiff_strip_size() {
+ tiff::ignore_warnings();
+ if let Some(t_handle) = tiff::open("../test.tif") {
+ let strip_size = tiff::get_strip_size(t_handle);
+ assert!(strip_size > 0);
+ println!("{:?}", strip_size);
+ tiff::close(t_handle);
+ } else {
+ assert!(false);
+ }
+ }
}
diff --git a/src/tiff.rs b/src/tiff.rs
index 7143664..04eaf02 100644
--- a/src/tiff.rs
+++ b/src/tiff.rs
@@ -22,6 +22,8 @@ unsafe extern "C" {
fn TIFFOpen(filename: *const c_char, mode: *const c_char) -> *mut TIFF;
fn TIFFClose(tiff_ptr: *mut TIFF);
fn TIFFGetField(tiff_ptr: *mut TIFF, tag: u32, ...) -> i32;
+ fn TIFFStripSize(tiff_ptr: *mut TIFF) -> i64;
+ fn TIFFNumberOfStrips(tiff_ptr: *mut TIFF) -> i64;
}
/// From tiff.h
@@ -72,3 +74,15 @@ pub fn get_height(tiff_ptr: *mut TIFF) -> u32 {
}
return height;
}
+
+pub fn get_strip_size(tiff_ptr: *mut TIFF) -> i64 {
+ unsafe {
+ TIFFStripSize(tiff_ptr)
+ }
+}
+
+pub fn get_strip_count(tiff_ptr: *mut TIFF) -> i64 {
+ unsafe {
+ TIFFNumberOfStrips(tiff_ptr)
+ }
+}