Merge pull request #37 from jimrybarski/master

Allow Decoder::next_image() to be called multiple times to allow paging through a multi-page TIFF
This commit is contained in:
Birk Tjelmeland authored and GitHub committed 2019-04-25 18:23:06 +02:00
commit 4609425be9
1 file changed
+4 -3
+4 -3
View File
@@ -314,13 +314,14 @@ impl<R: Read + Seek> Decoder<R> {
/// Initializes the decoder.
pub fn init(mut self) -> TiffResult<Decoder<R>> {
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<Decoder<R>> {
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));
@@ -365,7 +366,7 @@ impl<R: Read + Seek> Decoder<R> {
))
}
}
Ok(self)
Ok(())
}
/// Returns `true` if there is at least one more image available.