Skip to content

Commit cda2bcc

Browse files
committed
chunk_width and chunk_height without unwrap
1 parent d754e14 commit cda2bcc

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/ifd.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -686,22 +686,25 @@ impl ImageFileDirectory {
686686
panic!("bits_per_sample should be the same for all channels");
687687
}
688688

689+
let chunk_width = if let Some(tile_width) = self.tile_width {
690+
tile_width
691+
} else {
692+
self.image_width
693+
};
694+
let chunk_height = if let Some(tile_height) = self.tile_height {
695+
tile_height
696+
} else {
697+
self.rows_per_strip
698+
.expect("no tile height and no rows_per_strip")
699+
};
700+
689701
PredictorInfo {
690702
endianness: self.endianness,
691703
image_width: self.image_width,
692704
image_height: self.image_height,
693-
chunk_width: if self.tile_width.is_none() {
694-
// we are stripped => image_width
695-
self.image_width
696-
} else {
697-
self.tile_width.unwrap()
698-
},
699-
chunk_height: if self.tile_height.is_none() {
700-
self.rows_per_strip
701-
.expect("no tile height and no rows_per_strip")
702-
} else {
703-
self.tile_height.unwrap()
704-
},
705+
chunk_width,
706+
chunk_height,
707+
// TODO: validate this? Restore handling for different PlanarConfiguration?
705708
bits_per_sample: self.bits_per_sample[0],
706709
samples_per_pixel: self.samples_per_pixel,
707710
}

0 commit comments

Comments
 (0)