Expand description
A pure Rust no-std texture decoder for the following formats:
- ATC - Adreno Texture Compression
- ASTC - Adaptive Scalable Texture Compression
- BCn - Block Compression
- ETC - Ericsson Texture Compression
- PVRTC - PowerVR Texture Compression
- Crunch & Unity’s Crunch
§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:
- ATC
- ASTC
decode_astc()
decode_astc_block()
- various decode_astc_(block_)_x_y functions, where x and y are the block size
- BCn
- ETC
- PVRTC
- Crunch
- Unity Crunch
Structs§
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