Improve deflate support

- Switch to streaming decompression via `flate2`. Aside from performance improvements and lower RAM consumption, this fixes a bug where `max_uncompressed_length` was precalculated for a single tile but then used as a hard limit on the whole data, failing to decompress any tiled images.
 - Deprecate `InflateError` - this was used for wrapping `miniz_oxide` raw status, but `flate2` already reports them as `io::Error` instead. This makes errors from both Lzw and Deflate modes more consistent - they're all now just `io::Error`.
 - Add support for new `Deflate` tag in addition to `OldDeflate` - format-wise it's same Zlib, and on practice decodes successfully with the same underlying code.
 - Slightly simplify partial reads from the `Reader` by using the `std::io::copy` helper instead of doing it manually.

Fixes #131.
This commit is contained in:
Ingvar Stepanyan committed 2021-05-08 15:34:14 +01:00
1 parent a874b9c3a5
commit a6fb855121
5 files changed
+18 -78

No files matched your search

+4 -4
View File
@@ -7,7 +7,6 @@
//! * <https://www.adobe.io/open/standards/TIFF.html> - The TIFF specification
extern crate jpeg;
extern crate miniz_oxide;
extern crate weezl;
mod bytecast;
@@ -16,9 +15,10 @@ pub mod encoder;
mod error;
pub mod tags;
pub use self::error::{
InflateError, TiffError, TiffFormatError, TiffResult, TiffUnsupportedError, UsageError,
};
pub use self::error::{TiffError, TiffFormatError, TiffResult, TiffUnsupportedError, UsageError};
#[allow(deprecated)]
pub use self::error::InflateError;
/// An enumeration over supported color types and their bit depths
#[derive(Copy, PartialEq, Eq, Debug, Clone, Hash)]