Function asefile::util::to_indexed_image

source ·
pub fn to_indexed_image(
    image: RgbaImage,
    mapper: &PaletteMapper
) -> ((u32, u32), Vec<u8>)
Expand description

Turn an RgbaImage into an indexed image.

Returns image dimensions and raw index data.

§Example

use asefile::util::{PaletteMapper, MappingOptions, to_indexed_image};
let img = ase.frame(0).image();
assert!(ase.is_indexed_color());
let mapper = PaletteMapper::new(
    ase.palette().unwrap(),
    MappingOptions {
        transparent: ase.transparent_color_index(),
        failure: 0,
    }
);
let ((w, h), data) = to_indexed_image(img, &mapper);
assert_eq!(data.len(), (w * h) as usize);