File: test_transcoder_astc.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 (18 lines) | stat: -rw-r--r-- 506 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from basisu_py import Transcoder
from astc_writer import write_astc_file

# Load a .ktx2
data = open("input.ktx2", "rb").read()
t = Transcoder()

# Transcode to ASTC
h = t.open(data)
bw = t.get_block_width(h)   # or basis_get_block_width(astc_tfmt)
bh = t.get_block_height(h)
tfmt = t.basis_get_transcoder_texture_format_from_basis_tex_format(
    t.get_basis_tex_format(h)
)

blocks = t.transcode_tfmt(data, tfmt)
write_astc_file("output.astc", blocks, bw, bh, t.get_width(h), t.get_height(h))
t.close(h)