Blender V5.3
ktx_bridge/intern/decoder.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include "common.h"
8
9#include <ktx.h>
10
11#include <stddef.h>
12
13/* Loads a KTX2 file and, if needed (e.g. Basis Universal supercompression),
14 * transcodes it to raw RGBA8 so `getImageDataFloat()` always returns plain pixels. */
15API(int)
16decodeFromFile(const char *filename, ktxTexture2 **newTex);
17
18API(int)
19getImageInfo(ktxTexture2 *texture, unsigned int *width, unsigned int *height, size_t *dataSize);
20
21/* Normalizes each RGBA8 byte to a [0, 1] float and flips rows so the result is bottom-to-top,
22 * matching Blender's `ImBuf`/`Image.pixels` convention (KTX stores rows top-to-bottom).
23 * `destinationSize` is in bytes. */
24API(int)
25getImageDataFloat(ktxTexture2 *texture, float *destination, size_t destinationSize);
26
27API(void)
28destroyTexture(ktxTexture2 *texture);
#define API(returnType)
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
int getImageDataFloat(ktxTexture2 *texture, float *destination, size_t destinationSize)
void destroyTexture(ktxTexture2 *texture)
int decodeFromFile(const char *filename, ktxTexture2 **newTex)
int getImageInfo(ktxTexture2 *texture, unsigned int *width, unsigned int *height, size_t *dataSize)