A PVRTC decoder for PIL.
The decoder uses PVRTDecompress from PVRCore to decompress the data.
- Cython required
pip install pvrtc_decoder
python setup.py install
do2bit_mode:
- 0 - PVRTC2 (8 bit)
- 1 - PVRTC4 (16 bit)
from PIL import Image
import pvrtc_decoder
#needs to be imported once in the active code, so that the codec can register itself
raw_pvrtc_image_data : bytes
do2bit_mode = 0 # see above
img = Image.frombytes('RGBA', size, raw_pvrtc_image_data, 'pvrtc', (do2bit_mode))
from pvrtc_decoder import decompress_pvrtc, decompress_etc
# compressed PVRTC image bytes to RGBA bytes
rgba_data = decompress_pvrtc(compressed_data : bytes, do2bit_mode : int, width : int, height : int)
# compressed ETC image bytes to RGBA bytes
# mode seems to be unused, so use any value you want
rgba_data = decompress_etc(src_data : bytes, width : int, height : int, mode : int)