Fix 1bpp image decoding and add a test image (#252)
This commit is contained in:
1 parent
e28ad564d9
commit
96d3a02efe
4 files changed
+17
-7
No files matched your search
@@ -687,8 +687,6 @@ impl Image {
|
||||
let row = &mut row[..data_row_bytes];
|
||||
reader.read_exact(row)?;
|
||||
|
||||
println!("chunk={chunk_index}, index={i}");
|
||||
|
||||
// Skip horizontal padding
|
||||
if chunk_row_bytes > data_row_bytes {
|
||||
let len = u64::try_from(chunk_row_bytes - data_row_bytes)?;
|
||||
|
||||
+12
-5
@@ -969,13 +969,20 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
}
|
||||
|
||||
fn result_buffer(&self, width: usize, height: usize) -> TiffResult<DecodingResult> {
|
||||
let buffer_size = match width
|
||||
let bits_per_sample = self.image().bits_per_sample;
|
||||
|
||||
let row_samples = if bits_per_sample >= 8 {
|
||||
width
|
||||
} else {
|
||||
((((width as u64) * bits_per_sample as u64) + 7) / 8)
|
||||
.try_into()
|
||||
.map_err(|_| TiffError::LimitsExceeded)?
|
||||
};
|
||||
|
||||
let buffer_size = row_samples
|
||||
.checked_mul(height)
|
||||
.and_then(|x| x.checked_mul(self.image().samples_per_pixel()))
|
||||
{
|
||||
Some(s) => s,
|
||||
None => return Err(TiffError::LimitsExceeded),
|
||||
};
|
||||
.ok_or(TiffError::LimitsExceeded)?;
|
||||
|
||||
let max_sample_bits = self.image().bits_per_sample;
|
||||
match self.image().sample_format {
|
||||
|
||||
@@ -216,6 +216,11 @@ fn issue_69() {
|
||||
//assert!(img_res.is_ok());
|
||||
//}
|
||||
|
||||
#[test]
|
||||
fn test_tiled_gray_i1() {
|
||||
test_image_sum_u8("tiled-gray-i1.tif", ColorType::Gray(1), 30531);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tiled_rgb_u8() {
|
||||
test_image_sum_u8("tiled-rgb-u8.tif", ColorType::RGB(8), 39528948);
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user