Expand description
Decoding of DXT (S3TC) compression
DXT is an image format that supports lossy compression
Β§Related Links
- https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_compression_s3tc.txt - Description of the DXT compression OpenGL extensions.
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.