Add TIFF compression and corresponding tests

This commit is contained in:
Christopher Gundler committed 2021-12-21 16:47:11 +01:00
1 parent d7d63e648b
commit 99b2aa9b3a
10 files changed
+676 -135

No files matched your search

+13
View File
@@ -10,6 +10,8 @@ use crate::tags::{
};
use crate::ColorType;
use crate::weezl::LzwError;
/// Tiff error kinds.
#[derive(Debug)]
pub enum TiffError {
@@ -31,6 +33,9 @@ pub enum TiffError {
/// The image does not support the requested operation
UsageError(UsageError),
/// An error has occurred during data compression
CompressionError,
}
/// The image is not formatted properly.
@@ -228,6 +233,7 @@ impl fmt::Display for TiffError {
TiffError::LimitsExceeded => write!(fmt, "The Decoder limits are exceeded"),
TiffError::IntSizeError => write!(fmt, "Platform or format size limits exceeded"),
TiffError::UsageError(ref e) => write!(fmt, "Usage error: {}", e),
TiffError::CompressionError => write!(fmt, "Compression failed"),
}
}
}
@@ -241,6 +247,7 @@ impl Error for TiffError {
TiffError::LimitsExceeded => "Decoder limits exceeded",
TiffError::IntSizeError => "Platform or format size limits exceeded",
TiffError::UsageError(..) => "Invalid usage",
TiffError::CompressionError => "Compression failed",
}
}
@@ -288,5 +295,11 @@ impl From<std::num::TryFromIntError> for TiffError {
}
}
impl From<LzwError> for TiffError {
fn from(_err: LzwError) -> TiffError {
TiffError::CompressionError
}
}
/// Result of an image decoding/encoding process
pub type TiffResult<T> = Result<T, TiffError>;