From 198f3ff3dc2c29da8eb6d66f9fa84b5448666809 Mon Sep 17 00:00:00 2001 From: Jim Rybarski Date: Thu, 28 Mar 2019 15:14:44 -0500 Subject: [PATCH] Allow Decoder::next_image() to be called multiple times to allow paging through a multi-page TIFF --- src/decoder/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs index 1cd8542..14c88a8 100644 --- a/src/decoder/mod.rs +++ b/src/decoder/mod.rs @@ -224,13 +224,14 @@ impl Decoder { /// Initializes the decoder. pub fn init(mut self) -> TiffResult> { try!(self.read_header()); - self.next_image() + self.next_image()?; + Ok(self) } /// Reads in the next image. /// If there is no further image in the TIFF file a format error is returned. /// To determine whether there are more images call `TIFFDecoder::more_images` instead. - pub fn next_image(mut self) -> TiffResult> { + pub fn next_image(&mut self) -> TiffResult<()> { self.ifd = Some(try!(self.read_ifd())); self.width = try!(self.get_tag_u32(ifd::Tag::ImageWidth)); self.height = try!(self.get_tag_u32(ifd::Tag::ImageLength)); @@ -266,7 +267,7 @@ impl Decoder { } _ => return Err(TiffError::UnsupportedError(TiffUnsupportedError::UnsupportedSampleDepth(self.samples))) } - Ok(self) + Ok(()) } /// Returns `true` if there is at least one more image available.