File: test_basic_decode.py

package info (click to toggle)
basis-universal 2.0.2-3
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 216,436 kB
  • sloc: cpp: 163,224; ansic: 51,368; python: 2,824; javascript: 2,637; lisp: 1,026; sh: 161; makefile: 17
file content (19 lines) | stat: -rw-r--r-- 424 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from basisu_py import Transcoder
from PIL import Image
import numpy as np

# Load input file
with open("test.ktx2", "rb") as f:
    data = f.read()

# Decode (AUTO backend)
t = Transcoder()
rgba = t.decode_rgba(data)   # returns HxWx4 uint8 NumPy array

print("Decoded:", rgba.shape, rgba.dtype)

# Convert to Pillow Image and save
img = Image.fromarray(rgba, mode="RGBA")
img.save("decoded.png")

print("Wrote decoded.png")