Added tests and finalized i8 support
This commit is contained in:
1 parent
aa13e31894
commit
cd2f4f6462
4 files changed
+26
No files matched your search
@@ -923,6 +923,12 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
reader.read_u64_into(&mut buffer[..bytes / 8])?;
|
||||
bytes / 8
|
||||
}
|
||||
(ColorType::RGBA(8), DecodingBuffer::I8(ref mut buffer))
|
||||
| (ColorType::RGB(8), DecodingBuffer::I8(ref mut buffer))
|
||||
| (ColorType::CMYK(8), DecodingBuffer::I8(ref mut buffer)) => {
|
||||
reader.read_i8_into(&mut buffer[..bytes])?;
|
||||
bytes
|
||||
}
|
||||
(ColorType::RGBA(16), DecodingBuffer::I16(ref mut buffer))
|
||||
| (ColorType::RGB(16), DecodingBuffer::I16(ref mut buffer))
|
||||
| (ColorType::CMYK(16), DecodingBuffer::I16(ref mut buffer)) => {
|
||||
@@ -957,6 +963,15 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
}
|
||||
bytes / 2
|
||||
}
|
||||
(ColorType::Gray(8), DecodingBuffer::I8(ref mut buffer)) => {
|
||||
reader.read_i8_into(&mut buffer[..bytes])?;
|
||||
if self.photometric_interpretation == PhotometricInterpretation::WhiteIsZero {
|
||||
for datum in buffer[..bytes].iter_mut() {
|
||||
*datum = !*datum;
|
||||
}
|
||||
}
|
||||
bytes
|
||||
}
|
||||
// The following conversions interpret the image as in libtiff.
|
||||
// In particular, MIN is white and MAX is black and not Zero as the name would imply.
|
||||
(ColorType::Gray(16), DecodingBuffer::I16(ref mut buffer)) => {
|
||||
|
||||
@@ -29,6 +29,7 @@ macro_rules! test_image_sum {
|
||||
}
|
||||
|
||||
test_image_sum!(test_image_sum_u8, U8, u64);
|
||||
test_image_sum!(test_image_sum_i8, I8, i64);
|
||||
test_image_sum!(test_image_sum_u16, U16, u64);
|
||||
test_image_sum!(test_image_sum_i16, I16, i64);
|
||||
test_image_sum!(test_image_sum_u32, U32, u64);
|
||||
@@ -136,6 +137,16 @@ fn test_rgb_f32() {
|
||||
test_image_sum_f32("gradient-3c-32b-float.tiff", ColorType::RGB(32), 472.8405);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_int8() {
|
||||
test_image_sum_i8("int8.tif", ColorType::Gray(8), 3111)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_int8_rgb() {
|
||||
test_image_sum_i8("int8_rgb.tif", ColorType::RGB(8), -10344)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_int16() {
|
||||
test_image_sum_i16("int16.tif", ColorType::Gray(16), 354396);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user