πDeprecated: DXT support will be removed or reworked in a future version. Prefer the
squish
crate instead. See https://github.com/image-rs/image/issues/1623Expand 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§
- DxtDecoderDeprecatedDXT decoder
- DxtEncoderDeprecatedDXT encoder
- DxtReaderDeprecatedDXT reader
Enums§
- DxtVariantDeprecatedWhat 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§
- 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]
- Decodes a 8-byte bock of dxt5 data to a 16xRGB block
- Decode a row of DXT1 data to four rows of RGB data. source.len() should be a multiple of 8, otherwise this panics.
- Decodes a 16-byte bock of dxt3 data to a 16xRGBA block
- Decode a row of DXT3 data to four rows of RGBA data. source.len() should be a multiple of 16, otherwise this panics.
- Decodes a 16-byte bock of dxt5 data to a 16xRGBA block
- Decode a row of DXT5 data to four rows of RGBA data. source.len() should be a multiple of 16, otherwise this panics.
- 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)
- returns the squared error between two RGB values
- 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
- encodes an 8-bit RGB value into a 5-bit R, 6-bit G, 5-bit B 16-bit packed color value mapping preserves min/max values. It is guaranteed that i == encode(decode(i)) for all i
- Encodes a RGBx16 sequence of bytes into a 8 bytes DXT1 block
- Decode a row of DXT1 data to four rows of RGBA data. source.len() should be a multiple of 8, otherwise this panics.
- Encodes a RGBAx16 sequence of bytes into a 16 bytes DXT3 block
- Decode a row of DXT3 data to four rows of RGBA data. source.len() should be a multiple of 16, otherwise this panics.
- Encodes a buffer of 16 alpha bytes into a dxt5 alpha index table, where the alpha table they are indexed against is created by calling alpha_table_dxt5(alpha0, alpha1) returns the resulting error and alpha table
- Encodes a RGBAx16 sequence of bytes to a 16 bytes DXT5 block
- Decode a row of DXT5 data to four rows of RGBA data. source.len() should be a multiple of 16, otherwise this panics.
- Tries to perform the color encoding part of dxt compression the approach taken is simple, it picks unique combinations of the colors present in the block, and attempts to encode the block with each, picking the encoding that yields the least squared error out of all of them.
- utility function: squares a value