pub fn astc_decode<R: Read, F: FnMut(u32, u32, [u8; 4])>(
input: R,
width: u32,
height: u32,
footprint: Footprint,
writer: F,
) -> Result<()>Expand description
Decode an ASTC image, assuming linear block layout.
inputus used to read raw ASTC data.widthandheightspecify the image dimensions.footprintspecifies the footprint size.writeris a function with signatureFnMut(x: u32, y: u32, color: [u8; 4]). It is used to output decoded pixels. This function will be called once for each pixel(x, y)in the rectangle[0, width) * [0, height). Each element incolorrepresents the R, G, B, and A channel, respectively.- Returns success or IO error encountered when reading
input.
let footprint = astc_decode::Footprint::new(6, 6);
// Exmaple input. Not necessarily valid ASTC image
let input = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
let mut output = [[0; 4]; 5 * 3];
astc_decode::astc_decode(&input[..], 5, 3, footprint, |x, y, color| {
output[(x + y * 5) as usize] = color;
}).unwrap();