Function bcndecode::decode [] [src]

pub fn decode(
    source: &[u8],
    width: usize,
    height: usize,
    encoding: BcnEncoding,
    format: BcnDecoderFormat
) -> Result<Vec<u8>, Error>

Decodes the given BCN encoded image data. On success, the decoded data as a byte vector is returned.

Arguments

  • source - A byte slice that holds the data of the compressed image
  • width - Width of the encoded image in pixels
  • height - Width of the encoded image in pixels
  • encoding - Encoding type of the image.
  • format - Image format.

Errors

This function will return an error if the data cannot be decoded with the given parameters.

Examples

use bcndecode;
use std::fs::File;
use std::io::Read;

let mut compressed_file = File::open("testdata/images/copyright_2048_compressed.dat")?;
let mut compressed_data = Vec::new();

compressed_file.read_to_end(&mut compressed_data)?;

let decompressed_data = bcndecode::decode(
    &compressed_data,
    2048,
    2048,
    bcndecode::BcnEncoding::Bc3,
    bcndecode::BcnDecoderFormat::RGBA,
)?;