Files
Dylan M. Taylor 5c0b0a3632 Deduplicate raster codecs via shared image implementations (successor to #1198) (#1331)
* Share small raster format implementations

(cherry picked from commit 7aedc1de73)

* Preserve raster facade encode contracts

(cherry picked from commit 2db7c82705)

* Allow alpha in IFF compatibility encoder

(cherry picked from commit 80b55dee5a)

* Test shared raster facade contracts and refresh lockfile
2026-11-14 20:46:22 -05:00

17 lines
767 B
Rust

//! IFF/ILBM compatibility facade; implementation lives in craft-image-codecs.
use crate::{CodecError, Image, Limits, bridge};
use craft_image_codecs::Format;
pub fn looks_like_iff(bytes: &[u8]) -> bool {
craft_image_codecs::detect(bytes) == Some(Format::Iff)
}
pub fn decode(bytes: &[u8], limits: &Limits) -> Result<Image, CodecError> {
bridge::format(Format::Iff, bytes, limits)
}
pub fn encode(image: &Image) -> Result<Vec<u8>, CodecError> {
if !matches!(image.layout(), crate::ChannelLayout::Rgb | crate::ChannelLayout::Rgba) || image.sample_type() != crate::SampleType::U8 {
return Err(CodecError::encode("IFF", "ILBM writer stores 8-bit RGB pixels with optional alpha"));
}
bridge::encode(image, Format::Iff, &Default::default())
}