Module dxt

Source
Expand description

Decoding of DXT (S3TC) compression

DXT is an image format that supports lossy compression

Note: this module only implements bare DXT encoding/decoding, it does not parse formats that can contain DXT files like .dds

StructsΒ§

DxtDecoder πŸ”’
DXT decoder

EnumsΒ§

DxtVariant πŸ”’
What version of DXT compression are we using? Note that DXT2 and DXT4 are left away as they’re just DXT3 and DXT5 with premultiplied alpha

FunctionsΒ§

alpha_table_dxt5 πŸ”’
Constructs the DXT5 alpha lookup table from the two alpha entries if alpha0 > alpha1, constructs a table of [a0, a1, 6 linearly interpolated values from a0 to a1] if alpha0 <= alpha1, constructs a table of [a0, a1, 4 linearly interpolated values from a0 to a1, 0, 0xFF]
decode_dxt1_block πŸ”’
Decodes a 8-byte bock of dxt5 data to a 16xRGB block
decode_dxt1_row πŸ”’
Decode a row of DXT1 data to four rows of RGB data. source.len() should be a multiple of 8, otherwise this panics.
decode_dxt3_block πŸ”’
Decodes a 16-byte bock of dxt3 data to a 16xRGBA block
decode_dxt3_row πŸ”’
Decode a row of DXT3 data to four rows of RGBA data. source.len() should be a multiple of 16, otherwise this panics.
decode_dxt5_block πŸ”’
Decodes a 16-byte bock of dxt5 data to a 16xRGBA block
decode_dxt5_row πŸ”’
Decode a row of DXT5 data to four rows of RGBA data. source.len() should be a multiple of 16, otherwise this panics.
decode_dxt_colors πŸ”’
decodes an 8-byte dxt color block into the RGB channels of a 16xRGB or 16xRGBA block. source should have a length of 8, dest a length of 48 (RGB) or 64 (RGBA)
enc565_decode πŸ”’
decodes a 5-bit R, 6-bit G, 5-bit B 16-bit packed color value into 8-bit RGB mapping is done so min/max range values are preserved. So for 5-bit values 0x00 -> 0x00 and 0x1F -> 0xFF

Type AliasesΒ§

Rgb πŸ”’
Actual encoding/decoding logic below.