Ktx1Bundle

class Ktx1Bundle(nativeHandle: NativePointer) : AutoCloseable

An in-memory representation of a KTX1 file: a hierarchy of blobs (miplevels, array elements, cubemap faces) and metadata.

See also

Constructors

Link copied to clipboard
constructor(nativeHandle: NativePointer)
constructor(numMipLevels: Int, arrayLength: Int, isCubemap: Boolean)

Creates a hierarchy of empty texture blobs, to be filled before serializing.

constructor(bytes: ByteArray)

Creates a hierarchy of blobs by parsing the contents of a KTX file; bytes are copied.

Properties

Link copied to clipboard

The number of array elements, which is 1 for a plain texture.

Link copied to clipboard

Whether the bundle holds a cubemap (6 faces per miplevel and array element).

Link copied to clipboard

The native object, for interop with code calling the Fila* C API directly. Read-only: this wrapper owns it.

Link copied to clipboard

The number of miplevels.

Link copied to clipboard

The size of the KTX file serialize writes.

Functions

Link copied to clipboard
open override fun close()

Same as destroy; lets this be used with use { } and try-with-resources.

Link copied to clipboard
fun destroy()

Frees the bundle, unless Ktx1Reader.createTexture took it.

Link copied to clipboard

The KTX metadata value of key, or null if it has none.

Link copied to clipboard

Parses the key="sh" metadata into result: 3 bands of spherical harmonics, 9 RGB coefficients (27 floats).

Link copied to clipboard
fun serialize(destination: ByteArray): Boolean

Writes out the KTX file into destination, which must hold serializedLength bytes; false if it's too small.

Link copied to clipboard
fun setMetadata(key: String, value: String)

Adds a key/value pair to the KTX metadata.