Merge pull request #153 from mindQ-GmbH-Co-KG/compression-release
fixed deflate and packbits
This commit is contained in:
3 files changed
+9
-3
No files matched your search
@@ -53,7 +53,7 @@ impl Compression for Deflate {
|
||||
impl CompressionAlgorithm for Deflate {
|
||||
fn write_to<W: Write>(&mut self, writer: &mut W, bytes: &[u8]) -> Result<u64, io::Error> {
|
||||
let mut encoder = ZlibEncoder::new(writer, self.level);
|
||||
encoder.write(&bytes)?;
|
||||
encoder.write_all(&bytes)?;
|
||||
encoder.try_finish()?;
|
||||
Ok(encoder.total_out())
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ impl CompressionAlgorithm for Packbits {
|
||||
bufwriter.write(&bytes[pending_index..pending_index + bytes_pending as usize])?;
|
||||
}
|
||||
|
||||
bufwriter.flush()?;
|
||||
Ok(bytes_written)
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -12,7 +12,7 @@ use std::{
|
||||
|
||||
use crate::{
|
||||
error::TiffResult,
|
||||
tags::{ResolutionUnit, Tag},
|
||||
tags::{CompressionMethod, ResolutionUnit, Tag},
|
||||
};
|
||||
|
||||
pub mod colortype;
|
||||
@@ -354,7 +354,12 @@ impl<'a, W: 'a + Write + Seek, T: ColorType, K: TiffKind, D: Compression>
|
||||
|
||||
// Limit the strip size to prevent potential memory and security issues.
|
||||
// Also keep the multiple strip handling 'oiled'
|
||||
let rows_per_strip = (1_000_000 + row_bytes - 1) / row_bytes;
|
||||
let rows_per_strip = {
|
||||
match D::COMPRESSION_METHOD {
|
||||
CompressionMethod::PackBits => 1, // Each row must be packed separately. Do not compress across row boundaries
|
||||
_ => (1_000_000 + row_bytes - 1) / row_bytes,
|
||||
}
|
||||
};
|
||||
|
||||
let strip_count = (u64::from(height) + rows_per_strip - 1) / rows_per_strip;
|
||||
|
||||
|
||||
Reference in new issue
Block a user