Added unsupported error for interpretations not supported by JPEG
This commit is contained in:
1 parent
7307e96782
commit
4f1c88e35f
2 files changed
+15
-7
No files matched your search
@@ -358,7 +358,6 @@ impl Image {
|
|||||||
PhotometricInterpretation::BlackIsZero => {
|
PhotometricInterpretation::BlackIsZero => {
|
||||||
decoder.set_color_transform(jpeg::ColorTransform::None)
|
decoder.set_color_transform(jpeg::ColorTransform::None)
|
||||||
}
|
}
|
||||||
PhotometricInterpretation::RGBPalette => todo!(),
|
|
||||||
PhotometricInterpretation::TransparencyMask => {
|
PhotometricInterpretation::TransparencyMask => {
|
||||||
decoder.set_color_transform(jpeg::ColorTransform::None)
|
decoder.set_color_transform(jpeg::ColorTransform::None)
|
||||||
}
|
}
|
||||||
@@ -368,8 +367,13 @@ impl Image {
|
|||||||
PhotometricInterpretation::YCbCr => {
|
PhotometricInterpretation::YCbCr => {
|
||||||
decoder.set_color_transform(jpeg::ColorTransform::YCbCr)
|
decoder.set_color_transform(jpeg::ColorTransform::YCbCr)
|
||||||
}
|
}
|
||||||
PhotometricInterpretation::CIELab => todo!(),
|
photometric_interpretation => {
|
||||||
_ => todo!(),
|
return Err(TiffError::UnsupportedError(
|
||||||
|
TiffUnsupportedError::UnsupportedInterpretation(
|
||||||
|
photometric_interpretation,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = decoder.decode()?;
|
let data = decoder.decode()?;
|
||||||
|
|||||||
+8
-4
@@ -148,10 +148,8 @@ pub enum TiffUnsupportedError {
|
|||||||
UnsupportedBitsPerChannel(u8),
|
UnsupportedBitsPerChannel(u8),
|
||||||
UnsupportedPlanarConfig(Option<PlanarConfiguration>),
|
UnsupportedPlanarConfig(Option<PlanarConfiguration>),
|
||||||
UnsupportedDataType,
|
UnsupportedDataType,
|
||||||
|
UnsupportedInterpretation(PhotometricInterpretation),
|
||||||
UnsupportedJpegFeature(UnsupportedFeature),
|
UnsupportedJpegFeature(UnsupportedFeature),
|
||||||
#[doc(hidden)]
|
|
||||||
/// Do not match against this variant. It may get removed.
|
|
||||||
__NonExhaustive,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for TiffUnsupportedError {
|
impl fmt::Display for TiffUnsupportedError {
|
||||||
@@ -197,10 +195,16 @@ impl fmt::Display for TiffUnsupportedError {
|
|||||||
write!(fmt, "Unsupported planar configuration “{:?}”.", config)
|
write!(fmt, "Unsupported planar configuration “{:?}”.", config)
|
||||||
}
|
}
|
||||||
UnsupportedDataType => write!(fmt, "Unsupported data type."),
|
UnsupportedDataType => write!(fmt, "Unsupported data type."),
|
||||||
|
UnsupportedInterpretation(interpretation) => {
|
||||||
|
write!(
|
||||||
|
fmt,
|
||||||
|
"Unsupported photometric interpretation \"{:?}\".",
|
||||||
|
interpretation
|
||||||
|
)
|
||||||
|
}
|
||||||
UnsupportedJpegFeature(ref unsupported_feature) => {
|
UnsupportedJpegFeature(ref unsupported_feature) => {
|
||||||
write!(fmt, "Unsupported JPEG feature {:?}", unsupported_feature)
|
write!(fmt, "Unsupported JPEG feature {:?}", unsupported_feature)
|
||||||
}
|
}
|
||||||
__NonExhaustive => unreachable!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user