Removed passing of PhotometricInterpretation to create_reader

as this is now handled for JPEG globally
This commit is contained in:
Alan Race committed 2022-04-30 14:55:52 +02:00
1 parent ce00bb5a28
commit a133056287
2 files changed
+3 -21

No files matched your search

+3 -16
View File
@@ -1032,17 +1032,11 @@ impl<R: Read + Seek> Decoder<R> {
self.goto_offset_u64(offset)?; self.goto_offset_u64(offset)?;
let byte_order = self.reader.byte_order; let byte_order = self.reader.byte_order;
let photometric_interpretation = self.image().photometric_interpretation;
let compression_method = self.image().compression_method; let compression_method = self.image().compression_method;
let jpeg_tables = self.image().jpeg_tables.clone(); let jpeg_tables = self.image().jpeg_tables.clone();
let reader = Self::create_reader( let reader =
&mut self.reader, Self::create_reader(&mut self.reader, compression_method, length, jpeg_tables)?;
photometric_interpretation,
compression_method,
length,
jpeg_tables,
)?;
// Read into output buffer. // Read into output buffer.
{ {
@@ -1105,7 +1099,6 @@ impl<R: Read + Seek> Decoder<R> {
let mut reader = Self::create_reader( let mut reader = Self::create_reader(
&mut self.reader, &mut self.reader,
photometric_interpretation,
compression_method, compression_method,
compressed_length, compressed_length,
jpeg_tables, jpeg_tables,
@@ -1149,7 +1142,6 @@ impl<R: Read + Seek> Decoder<R> {
fn create_reader<'r>( fn create_reader<'r>(
reader: &'r mut SmartReader<R>, reader: &'r mut SmartReader<R>,
photometric_interpretation: PhotometricInterpretation,
compression_method: CompressionMethod, compression_method: CompressionMethod,
compressed_length: u64, compressed_length: u64,
jpeg_tables: Option<Arc<Vec<u8>>>, jpeg_tables: Option<Arc<Vec<u8>>>,
@@ -1170,12 +1162,7 @@ impl<R: Read + Seek> Decoder<R> {
)); ));
} }
let jpeg_reader = JpegReader::new( let jpeg_reader = JpegReader::new(reader, compressed_length, jpeg_tables)?;
reader,
compressed_length,
jpeg_tables,
&photometric_interpretation,
)?;
let mut decoder = jpeg::Decoder::new(jpeg_reader); let mut decoder = jpeg::Decoder::new(jpeg_reader);
let data = decoder.decode().unwrap(); let data = decoder.decode().unwrap();
-5
View File
@@ -192,8 +192,6 @@ impl<R: Read> Read for LZWReader<R> {
pub(crate) struct JpegReader { pub(crate) struct JpegReader {
jpeg_tables: Option<Arc<Vec<u8>>>, jpeg_tables: Option<Arc<Vec<u8>>>,
photometric_interpretation: Option<PhotometricInterpretation>,
buffer: io::Cursor<Vec<u8>>, buffer: io::Cursor<Vec<u8>>,
offset: usize, offset: usize,
@@ -216,7 +214,6 @@ impl JpegReader {
reader: &mut SmartReader<R>, reader: &mut SmartReader<R>,
length: u64, length: u64,
jpeg_tables: Option<Arc<Vec<u8>>>, jpeg_tables: Option<Arc<Vec<u8>>>,
photometric_interpretation: &PhotometricInterpretation,
) -> io::Result<JpegReader> ) -> io::Result<JpegReader>
where where
R: Read + Seek, R: Read + Seek,
@@ -247,14 +244,12 @@ impl JpegReader {
Ok(JpegReader { Ok(JpegReader {
buffer, buffer,
jpeg_tables: Some(jpeg_tables), jpeg_tables: Some(jpeg_tables),
photometric_interpretation: Some(*photometric_interpretation),
offset: 0, offset: 0,
}) })
} }
None => Ok(JpegReader { None => Ok(JpegReader {
buffer: io::Cursor::new(segment), buffer: io::Cursor::new(segment),
jpeg_tables: None, jpeg_tables: None,
photometric_interpretation: None,
offset: 0, offset: 0,
}), }),
} }