fixed support for multipage images, the IDF offset is added during the new and also at the end of the internal_finish. This should only be done once

This commit is contained in:
Onno Kammeraad committed 2019-11-06 14:04:18 +01:00
1 parent 80b8ec5cdb
commit cbae42ea94
1 file changed
+5 -2
+5 -2
View File
@@ -1,6 +1,7 @@
use byteorder::NativeEndian;
use std::collections::BTreeMap;
use std::io::{Seek, Write};
use std::mem;
use decoder::ifd::{self, Tag};
use error::{TiffError, TiffFormatError, TiffResult};
@@ -351,6 +352,8 @@ impl<W: Write + Seek> TiffEncoder<W> {
};
NativeEndian::write_header(&mut encoder.writer)?;
// blank the IFD offset location
encoder.writer.write_u32(0)?;
Ok(encoder)
}
@@ -417,9 +420,9 @@ pub struct DirectoryEncoder<'a, W: 'a + Write + Seek> {
impl<'a, W: 'a + Write + Seek> DirectoryEncoder<'a, W> {
fn new(writer: &'a mut TiffWriter<W>) -> TiffResult<DirectoryEncoder<'a, W>> {
// the previous word is the IFD offset position
let ifd_pointer_pos = writer.offset() - mem::size_of::<u32>() as u64;
writer.pad_word_boundary()?;
let ifd_pointer_pos = writer.offset();
writer.write_u32(0)?;
Ok(DirectoryEncoder {
writer,
dropped: false,