Crate texture2ddecoder

Source
Expand description

A pure Rust no-std texture decoder for the following formats:

§Functions

Provides a decode function for each format, as well as a block decode function all formats besides PVRTC. Besides some exceptions, the signature of the decode functions is as follows:

    fn decode_format(data: &[u8], width: usize, height: usize, image: &mut [u32]) -> Result<(), &'static str>
    // data: the compressed data, expected to be width * height / block_size in size
    // width: the width of the image
    // height: the height of the image
    // image: the buffer to write the decoded image to, expected to be width * height in size
    fn decode_format_block(data: &[u8], image: &mut [u32]) -> Result<(), &'static str>
    // data: the compressed data (block), expected to be block_size in size
    // image: the buffer to write the decoded image to, expected to be block_size in size

The exceptions are:

  • ASTC: the (block) decode function takes the block size as an additional parameter
  • BC6: there are two additional decode functions for the signed and unsigned variants
  • PVRTC: the decode function takes the block size as an additional parameter, and there are two additional decode functions for the 2bpp and 4bpp variants
  • Crunch & Unity’s Crunch: The texture’s dimensions and metadata are stored in the file itself, one’s must parse the header with crnd_get_texture_info() from crn_texture_info struct first, then pass the metadata to the decoder as in the format. There’s no block decomp. function.

To make these excetions easier to use, there are helper functions to enable decode functions with identical arguments and returns.

Here is a list of the formats and their corresponding functions:

Structs§

CrnTextureInfo

Functions§

decode_astc
decode_astc_4_4
decode_astc_5_4
decode_astc_5_5
decode_astc_6_5
decode_astc_6_6
decode_astc_8_5
decode_astc_8_6
decode_astc_8_8
decode_astc_10_5
decode_astc_10_6
decode_astc_10_8
decode_astc_10_10
decode_astc_12_10
decode_astc_12_12
decode_astc_block
decode_atc_rgb4
Decodes a atc_rgb4 encoded texture into an image
decode_atc_rgb4_block
decode_atc_rgba8
Decodes a atc_rgba8 encoded texture into an image
decode_atc_rgba8_block
decode_bc1
Decodes a bc1 encoded texture into an image
decode_bc2
Decodes a bc2 encoded texture into an image
decode_bc3
Decodes a bc3 encoded texture into an image
decode_bc4
Decodes a bc4 encoded texture into an image
decode_bc5
Decodes a bc5 encoded texture into an image
decode_bc6
decode_bc7
Decodes a bc7 encoded texture into an image
decode_bc1_block
decode_bc1a
Decodes a bc1a encoded texture into an image
decode_bc1a_block
decode_bc2_block
decode_bc3_block
decode_bc4_block
decode_bc5_block
decode_bc6_block
decode_bc6_block_signed
decode_bc6_block_unsigned
decode_bc6_signed
Decodes a bc6_signed encoded texture into an image
decode_bc6_unsigned
Decodes a bc6_unsigned encoded texture into an image
decode_bc7_block
decode_crunch
decode_eac_block
decode_eac_signed_block
decode_eacr
Decodes a eacr encoded texture into an image
decode_eacr_block
decode_eacr_signed
Decodes a eacr_signed encoded texture into an image
decode_eacr_signed_block
decode_eacrg
Decodes a eacrg encoded texture into an image
decode_eacrg_block
decode_eacrg_signed
Decodes a eacrg_signed encoded texture into an image
decode_eacrg_signed_block
decode_etc1
Decodes a etc1 encoded texture into an image
decode_etc1_block
decode_etc2_a8_block
decode_etc2_rgb
Decodes a etc2_rgb encoded texture into an image
decode_etc2_rgb_block
decode_etc2_rgba1
Decodes a etc2_rgba1 encoded texture into an image
decode_etc2_rgba8
Decodes a etc2_rgba8 encoded texture into an image
decode_etc2_rgba1_block
decode_etc2_rgba8_block
decode_pvrtc
decode_pvrtc_2bpp
decode_pvrtc_4bpp
decode_unity_crunch