Skip to content

Commit

Permalink
Sample format should not be a Vec (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
fintelia committed Mar 23, 2024
1 parent 895c70a commit 9b06e37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/decoder/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub(crate) struct Image {
pub bits_per_sample: u8,
#[allow(unused)]
pub samples: u16,
pub sample_format: Vec<SampleFormat>,
pub sample_format: SampleFormat,
pub photometric_interpretation: PhotometricInterpretation,
pub compression_method: CompressionMethod,
pub predictor: Predictor,
Expand Down Expand Up @@ -155,9 +155,9 @@ impl Image {
return Err(TiffUnsupportedError::UnsupportedSampleFormat(sample_format).into());
}

sample_format
sample_format[0]
}
None => vec![SampleFormat::Uint],
None => SampleFormat::Uint,
};

let bits_per_sample: Vec<u8> = tag_reader
Expand Down
11 changes: 3 additions & 8 deletions src/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ impl<R: Read + Seek> Decoder<R> {
height: 0,
bits_per_sample: 1,
samples: 1,
sample_format: vec![SampleFormat::Uint],
sample_format: SampleFormat::Uint,
photometric_interpretation: PhotometricInterpretation::BlackIsZero,
compression_method: CompressionMethod::None,
jpeg_tables: None,
Expand Down Expand Up @@ -1065,12 +1065,7 @@ impl<R: Read + Seek> Decoder<R> {
};

let max_sample_bits = self.image().bits_per_sample;
match self
.image()
.sample_format
.first()
.unwrap_or(&SampleFormat::Uint)
{
match self.image().sample_format {
SampleFormat::Uint => match max_sample_bits {
n if n <= 8 => DecodingResult::new_u8(buffer_size, &self.limits),
n if n <= 16 => DecodingResult::new_u16(buffer_size, &self.limits),
Expand All @@ -1096,7 +1091,7 @@ impl<R: Read + Seek> Decoder<R> {
TiffUnsupportedError::UnsupportedBitsPerChannel(n),
)),
},
format => Err(TiffUnsupportedError::UnsupportedSampleFormat(vec![*format]).into()),
format => Err(TiffUnsupportedError::UnsupportedSampleFormat(vec![format]).into()),
}
}

Expand Down

0 comments on commit 9b06e37

Please sign in to comment.