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:
1 file changed
+4
-3
+4
-3
@@ -314,13 +314,14 @@ impl<R: Read + Seek> Decoder<R> {
|
|||||||
/// Initializes the decoder.
|
/// Initializes the decoder.
|
||||||
pub fn init(mut self) -> TiffResult<Decoder<R>> {
|
pub fn init(mut self) -> TiffResult<Decoder<R>> {
|
||||||
try!(self.read_header());
|
try!(self.read_header());
|
||||||
self.next_image()
|
self.next_image()?;
|
||||||
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads in the next image.
|
/// Reads in the next image.
|
||||||
/// If there is no further image in the TIFF file a format error is returned.
|
/// 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.
|
/// 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.ifd = Some(try!(self.read_ifd()));
|
||||||
self.width = try!(self.get_tag_u32(ifd::Tag::ImageWidth));
|
self.width = try!(self.get_tag_u32(ifd::Tag::ImageWidth));
|
||||||
self.height = try!(self.get_tag_u32(ifd::Tag::ImageLength));
|
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.
|
/// Returns `true` if there is at least one more image available.
|
||||||
|
|||||||
Reference in new issue
Block a user