2
2
use std:: fmt:: Debug ;
3
3
4
4
use bytes:: { Bytes , BytesMut } ;
5
- // use tiff::decoder::DecodingResult;
6
5
6
+ use crate :: error:: AsyncTiffError ;
7
7
use crate :: ImageFileDirectory ;
8
8
use crate :: { error:: AsyncTiffResult , reader:: Endianness } ;
9
9
@@ -78,12 +78,10 @@ impl PredictorInfo {
78
78
///
79
79
/// strips are considered image-width chunks
80
80
fn chunk_width_pixels ( & self , x : u32 ) -> AsyncTiffResult < u32 > {
81
- if x >= self . chunks_across ( ) {
82
- Err ( crate :: error:: AsyncTiffError :: TileIndexError (
83
- x,
84
- self . chunks_across ( ) ,
85
- ) )
86
- } else if x == self . chunks_across ( ) - 1 {
81
+ let chunks_across = self . chunks_across ( ) ;
82
+ if x >= chunks_across {
83
+ Err ( AsyncTiffError :: TileIndexError ( x, chunks_across) )
84
+ } else if x == chunks_across - 1 {
87
85
// last chunk
88
86
Ok ( self . image_width - self . chunk_width * x)
89
87
} else {
@@ -94,14 +92,11 @@ impl PredictorInfo {
94
92
/// chunk height in pixels, taking padding into account
95
93
///
96
94
/// strips are considered image-width chunks
97
- ///
98
95
fn chunk_height_pixels ( & self , y : u32 ) -> AsyncTiffResult < u32 > {
99
- if y >= self . chunks_down ( ) {
100
- Err ( crate :: error:: AsyncTiffError :: TileIndexError (
101
- y,
102
- self . chunks_down ( ) ,
103
- ) )
104
- } else if y == self . chunks_down ( ) - 1 {
96
+ let chunks_down = self . chunks_down ( ) ;
97
+ if y >= chunks_down {
98
+ Err ( AsyncTiffError :: TileIndexError ( y, chunks_down) )
99
+ } else if y == chunks_down - 1 {
105
100
// last chunk
106
101
Ok ( self . image_height - self . chunk_height * y)
107
102
} else {
0 commit comments