Function astc_decode::astc_decode[][src]

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.

  • input us used to read raw ASTC data.
  • width and height specify the image dimensions.
  • footprint specifies the footprint size.
  • writer is a function with signature FnMut(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 in color represents 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();