@@ -32,6 +32,7 @@ export interface IDecodedData {
height: number;
transcodedFormat: number;
mipmaps: Array<IMipmap>;
+ isInGammaSpace: boolean;
errors?: string;
}
@@ -129,7 +130,7 @@ export class KTX2Decoder {
const mipmaps: Array<IMipmap> = [];
const dataPromises: Array<Promise<Nullable<Uint8Array>>> = [];
const mipmapBuffers: Array<ArrayBuffer> = [];
- const decodedData: IDecodedData = { width: 0, height: 0, transcodedFormat, mipmaps };
+ const decodedData: IDecodedData = { width: 0, height: 0, transcodedFormat, mipmaps, isInGammaSpace: kfr.isInGammaSpace };
let firstImageDescIndex = 0;
@@ -29,6 +29,11 @@ const enum dfdChannel_UASTC {
RRRG = 5
+const enum dfdTransferFunction {
+ linear = 1,
+ sRGB = 2
+}
+
/** @hidden */
export interface IKTX2_Header {
vkFormat: number;
@@ -339,6 +344,10 @@ export class KTX2FileReader {
return this._header.supercompressionScheme === supercompressionScheme.ZStandard;
+ public get isInGammaSpace(): boolean {
+ return this._dfdBlock.transferFunction === dfdTransferFunction.sRGB;
+ }
public static IsValid(data: ArrayBufferView): boolean {
if (data.byteLength >= 12) {
// '«', 'K', 'T', 'X', ' ', '2', '0', '»', '\r', '\n', '\x1A', '\n'