Function astc_decode::astc_decode_block [−][src]
pub fn astc_decode_block<F: FnMut(u32, u32, [u8; 4])>(
input: &[u8; 16],
footprint: Footprint,
writer: F
) -> bool
Expand description
Decode an ASTC block from a 16-byte buffer.
input
contains the raw ASTC data for one block.footprint
specifies the footprint size.writer
is 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, footprint.width()) * [0, footprint.height())
. Each element incolor
represents the R, G, B, and A channel, respectively.- returns
true
if the block is successfully decoded;false
if the block contains illegal encoding.
let footprint = astc_decode::Footprint::new(6, 6); // Exmaple input. Not necessarily a valid ASTC block let input = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; let mut output = [[0; 4]; 6 * 6]; astc_decode::astc_decode_block(&input, footprint, |x, y, color| { output[(x + y * 6) as usize] = color; });