Crate texture2ddecoder
source ·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
- (WIP) 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 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
Functions
- Decodes a atc_rgb4 encoded texture into an image
- Decodes a atc_rgba8 encoded texture into an image
- Decodes a bc1 encoded texture into an image
- Decodes a bc3 encoded texture into an image
- Decodes a bc4 encoded texture into an image
- Decodes a bc5 encoded texture into an image
- Decodes a bc6_signed encoded texture into an image
- Decodes a bc6_unsigned encoded texture into an image
- Decodes a bc7 encoded texture into an image
- Decodes a eacr encoded texture into an image
- Decodes a eacr_signed encoded texture into an image
- Decodes a eacrg encoded texture into an image
- Decodes a eacrg_signed encoded texture into an image
- Decodes a etc1 encoded texture into an image
- Decodes a etc2_rgb encoded texture into an image
- Decodes a etc2_rgba1 encoded texture into an image
- Decodes a etc2_rgba8 encoded texture into an image