feat: Add decoding value and get tags as f32 or f64

This commit is contained in:
Etienne Prothon committed 2020-08-05 14:25:02 +02:00
1 parent 54c3ebf358
commit 3b0da4d1ae
3 files changed
+83 -3

No files matched your search

+22
View File
@@ -483,6 +483,18 @@ impl<R: Read + Seek> Decoder<R> {
self.reader.read_i32()
}
/// Reads a TIFF float value
#[inline]
pub fn read_float(&mut self) -> Result<f32, io::Error> {
self.reader.read_f32()
}
/// Reads a TIFF double value
#[inline]
pub fn read_double(&mut self) -> Result<f64, io::Error> {
self.reader.read_f64()
}
/// Reads a string
#[inline]
pub fn read_string(&mut self, length: usize) -> TiffResult<String> {
@@ -625,6 +637,16 @@ impl<R: Read + Seek> Decoder<R> {
self.get_tag(tag)?.into_u32_vec()
}
/// Tries to retrieve a tag and convert it to the desired type.
pub fn get_tag_f32_vec(&mut self, tag: Tag) -> TiffResult<Vec<f32>> {
self.get_tag(tag)?.into_f32_vec()
}
/// Tries to retrieve a tag and convert it to the desired type.
pub fn get_tag_f64_vec(&mut self, tag: Tag) -> TiffResult<Vec<f64>> {
self.get_tag(tag)?.into_f64_vec()
}
/// Decompresses the strip into the supplied buffer.
/// Returns the number of bytes read.
fn expand_strip<'a>(