Remove tile processing and add error handling
I removed the code that checked the tile attributes. Because I would rather later on PR something that works than a half-baked solution.
This commit is contained in:
1 parent
35ea719d9e
commit
cb900819d9
2 files changed
+14
-11
No files matched your search
+10
-11
@@ -931,20 +931,19 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
}
|
||||
|
||||
pub fn read_jpeg(&mut self) -> TiffResult<DecodingResult> {
|
||||
let offsets: Vec<u32>;
|
||||
let bytes: Vec<u32>;
|
||||
let offsets = self.get_tag_u32_vec(Tag::StripOffsets)?;
|
||||
let bytes = self.get_tag_u32_vec(Tag::StripByteCounts)?;
|
||||
let jpeg_tables: Vec<u8> = self.get_tag_u8_vec(Tag::JPEGTables)?;
|
||||
|
||||
match self.find_tag(Tag::TileOffsets) {
|
||||
Ok(None) => {
|
||||
offsets = self.get_tag_u32_vec(Tag::StripOffsets)?;
|
||||
bytes = self.get_tag_u32_vec(Tag::StripByteCounts)?;
|
||||
if offsets.len() == 0 {
|
||||
return Err(TiffError::FormatError(TiffFormatError::RequiredTagEmpty(
|
||||
Tag::StripOffsets,
|
||||
)));
|
||||
}
|
||||
Ok(_) => {
|
||||
offsets = self.get_tag_u32_vec(Tag::TileOffsets)?;
|
||||
bytes = self.get_tag_u32_vec(Tag::TileByteCounts)?;
|
||||
}
|
||||
Err(e) => return Err(e),
|
||||
if offsets.len() != bytes.len() {
|
||||
return Err(TiffError::FormatError(TiffFormatError::Format(
|
||||
String::from("Size mismatch of StripOffsets and StripByteCounts"),
|
||||
)));
|
||||
}
|
||||
|
||||
let mut res_img = Vec::with_capacity(offsets[0] as usize);
|
||||
|
||||
@@ -50,6 +50,7 @@ pub enum TiffFormatError {
|
||||
SignedIntegerExpected(Value),
|
||||
InflateError(InflateError),
|
||||
Format(String),
|
||||
RequiredTagEmpty(Tag),
|
||||
#[doc(hidden)]
|
||||
/// Do not match against this variant. It may get removed.
|
||||
__NonExhaustive,
|
||||
@@ -84,6 +85,9 @@ impl fmt::Display for TiffFormatError {
|
||||
Format(ref val) => {
|
||||
write!(fmt, "Invalid format: {:?}.", val)
|
||||
}
|
||||
RequiredTagEmpty(ref val) => {
|
||||
write!(fmt, "Required tag {:?} was empty.", val)
|
||||
}
|
||||
__NonExhaustive => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user