@@ -61,6 +61,14 @@ impl PredictorInfo {
61
61
chunk_width,
62
62
chunk_height,
63
63
// TODO: validate this? Restore handling for different PlanarConfiguration?
64
+ // PlanarConfiguration::Chunky => {
65
+ // if self.bits_per_sample.len() == 1 {
66
+ // self.samples_per_pixel as usize * self.bits_per_sample[0] as usize
67
+ // } else {
68
+ // assert_eq!(self.samples_per_pixel as usize, self.bits_per_sample.len());
69
+ // self.bits_per_sample.iter().map(|v| *v as usize).product()
70
+ // }
71
+ // }
64
72
bits_per_sample : ifd. bits_per_sample [ 0 ] ,
65
73
samples_per_pixel : ifd. samples_per_pixel ,
66
74
}
@@ -69,29 +77,6 @@ impl PredictorInfo {
69
77
/// chunk width in pixels, taking padding into account
70
78
///
71
79
/// strips are considered image-width chunks
72
- ///
73
- /// # Example
74
- ///
75
- /// ```rust
76
- /// # use async_tiff::tiff::tags::{SampleFormat, PlanarConfiguration};
77
- /// # use async_tiff::reader::Endianness;
78
- /// # use async_tiff::PredictorInfo;
79
- /// let info = PredictorInfo {
80
- /// # endianness: Endianness::LittleEndian,
81
- /// image_width: 15,
82
- /// image_height: 15,
83
- /// chunk_width: 8,
84
- /// chunk_height: 8,
85
- /// # bits_per_sample: &[32],
86
- /// # samples_per_pixel: 1,
87
- /// # sample_format: &[SampleFormat::IEEEFP],
88
- /// # planar_configuration: PlanarConfiguration::Chunky,
89
- /// };
90
- ///
91
- /// assert_eq!(info.chunk_width_pixels(0).unwrap(), (8));
92
- /// assert_eq!(info.chunk_width_pixels(1).unwrap(), (7));
93
- /// info.chunk_width_pixels(2).unwrap_err();
94
- /// ```
95
80
fn chunk_width_pixels ( & self , x : u32 ) -> AsyncTiffResult < u32 > {
96
81
if x >= self . chunks_across ( ) {
97
82
Err ( crate :: error:: AsyncTiffError :: TileIndexError (
@@ -110,29 +95,7 @@ impl PredictorInfo {
110
95
///
111
96
/// strips are considered image-width chunks
112
97
///
113
- /// # Example
114
- ///
115
- /// ```rust
116
- /// # use async_tiff::tiff::tags::{SampleFormat, PlanarConfiguration};
117
- /// # use async_tiff::reader::Endianness;
118
- /// # use async_tiff::PredictorInfo;
119
- /// let info = PredictorInfo {
120
- /// # endianness: Endianness::LittleEndian,
121
- /// image_width: 15,
122
- /// image_height: 15,
123
- /// chunk_width: 8,
124
- /// chunk_height: 8,
125
- /// # bits_per_sample: &[32],
126
- /// # samples_per_pixel: 1,
127
- /// # sample_format: &[SampleFormat::IEEEFP],
128
- /// # planar_configuration: PlanarConfiguration::Chunky,
129
- /// };
130
- ///
131
- /// assert_eq!(info.chunk_height_pixels(0).unwrap(), (8));
132
- /// assert_eq!(info.chunk_height_pixels(1).unwrap(), (7));
133
- /// info.chunk_height_pixels(2).unwrap_err();
134
- /// ```
135
- pub fn chunk_height_pixels ( & self , y : u32 ) -> AsyncTiffResult < u32 > {
98
+ fn chunk_height_pixels ( & self , y : u32 ) -> AsyncTiffResult < u32 > {
136
99
if y >= self . chunks_down ( ) {
137
100
Err ( crate :: error:: AsyncTiffError :: TileIndexError (
138
101
y,
@@ -147,39 +110,17 @@ impl PredictorInfo {
147
110
}
148
111
149
112
/// get the output row stride in bytes, taking padding into account
150
- pub fn output_row_stride ( & self , x : u32 ) -> AsyncTiffResult < usize > {
113
+ fn output_row_stride ( & self , x : u32 ) -> AsyncTiffResult < usize > {
151
114
Ok ( ( self . chunk_width_pixels ( x) ? as usize ) . saturating_mul ( self . bits_per_sample as _ ) / 8 )
152
115
}
153
116
154
- // /// The total number of bits per pixel, taking into account possible different sample sizes
155
- // ///
156
- // /// Technically bits_per_sample.len() should be *equal* to samples, but libtiff also allows
157
- // /// it to be a single value that applies to all samples.
158
- // ///
159
- // /// Libtiff and image-tiff do not support mixed bits per sample, but we give the possibility
160
- // /// unless you also have PlanarConfiguration::Planar, at which point the first is taken
161
- // pub fn bits_per_pixel(&self) -> usize {
162
- // self.bits_per_sample
163
- // match self.planar_configuration {
164
- // PlanarConfiguration::Chunky => {
165
- // if self.bits_per_sample.len() == 1 {
166
- // self.samples_per_pixel as usize * self.bits_per_sample[0] as usize
167
- // } else {
168
- // assert_eq!(self.samples_per_pixel as usize, self.bits_per_sample.len());
169
- // self.bits_per_sample.iter().map(|v| *v as usize).product()
170
- // }
171
- // }
172
- // PlanarConfiguration::Planar => self.bits_per_sample[0] as usize,
173
- // }
174
- // }
175
-
176
117
/// The number of chunks in the horizontal (x) direction
177
- pub fn chunks_across ( & self ) -> u32 {
118
+ fn chunks_across ( & self ) -> u32 {
178
119
self . image_width . div_ceil ( self . chunk_width )
179
120
}
180
121
181
122
/// The number of chunks in the vertical (y) direction
182
- pub fn chunks_down ( & self ) -> u32 {
123
+ fn chunks_down ( & self ) -> u32 {
183
124
self . image_height . div_ceil ( self . chunk_height )
184
125
}
185
126
}
0 commit comments