Ktx2Header Class

The immutable header, data format descriptor and key/value data of the KTX 2.0 file an image was decoded from. This is informational only, like ImageMetadata.SourceFormat: it describes the file, not the pixels.

public sealed class Ktx2Header : IEquatable<Ktx2Header>

Remarks

The decoder applies what changes the pixels the texture means: the component mapping of KTXswizzle (the channels a format lacks are 0, and alpha 1), and the transfer function and the primaries of the data format descriptor as the color labels of the image (ImageMetadata.TransferFunction, ImageMetadata.Cicp). KTXorientation is reported as ImageMetadata.Orientation, which AutoOrient applies.

No operation updates it, and every encoder ignores it.

Implements

Properties

NameDescription
AstcDecodeModeGets the value of KTXastcDecodeMode (rgb9e5 or unorm8), or null without it. It is reported, never applied.
ColorModelGets the color model of the data format descriptor (Khronos Data Format Specification, section 5.5), such as 1 (RGBSDA), 162 (ASTC) or 166 (UASTC).
ColorPrimariesGets the color primaries of the data format descriptor (section 5.7), such as 1 (BT.709) or 10 (Display P3).
FaceCountGets the number of faces: 6 for a cube map, 1 otherwise.
FormatNameGets the name of the format, such as R8G8B8A8_SRGB, ASTC_6x6_UNORM_BLOCK or UNDEFINED (UASTC).
KeyValueDataGets the key/value data: each value as it is stored, a NUL-terminated string included.
KeysGets the keys of the key/value data, in the order of the file.
LayerCountGets the number of array layers, or 0 for a texture that is not an array.
LevelCountGets the number of mip levels the file stores, or 0 when it stores the base level only and asks a loader to generate the others.
OrientationGets the value of KTXorientation, such as rd or ruo, or null without it.
PixelDepthGets the depth of the base level, in pixels, or 0 for a texture that is not three-dimensional.
PixelHeightGets the height of the base level, in pixels, or 0 for a one-dimensional texture.
PixelWidthGets the width of the base level, in pixels.
SupercompressionSchemeGets the supercompression scheme: 0 (none), 1 (BasisLZ), 2 (Zstandard) or 3 (ZLIB).
SwizzleGets the value of KTXswizzle, such as rrr1, or null without it.
TransferFunctionGets the transfer function of the data format descriptor (section 5.8), such as 1 (linear) or 2 (sRGB).
VkFormatGets the vkFormat of the header: a value of the Vulkan VkFormat enumeration, or 0 (VK_FORMAT_UNDEFINED) for Basis Universal data.
WriterGets the value of KTXwriter, the tool that wrote the file, or null without it.
WriterScParamsGets the value of KTXwriterScParams, the options of the tool that wrote the file, or null without it.

AstcDecodeMode

Ktx2Header.cs

Gets the value of KTXastcDecodeMode (rgb9e5 or unorm8), or null without it. It is reported, never applied.

public string? AstcDecodeMode { get; }

Property value

string?

ColorModel

Ktx2Header.cs

Gets the color model of the data format descriptor (Khronos Data Format Specification, section 5.5), such as 1 (RGBSDA), 162 (ASTC) or 166 (UASTC).

public int ColorModel { get; }

Property value

int

ColorPrimaries

Ktx2Header.cs

Gets the color primaries of the data format descriptor (section 5.7), such as 1 (BT.709) or 10 (Display P3).

public int ColorPrimaries { get; }

Property value

int

FaceCount

Ktx2Header.cs

Gets the number of faces: 6 for a cube map, 1 otherwise.

public int FaceCount { get; }

Property value

int

FormatName

Ktx2Header.cs

Gets the name of the format, such as R8G8B8A8_SRGB, ASTC_6x6_UNORM_BLOCK or UNDEFINED (UASTC).

public string FormatName { get; }

Property value

string

KeyValueData

Ktx2Header.cs

Gets the key/value data: each value as it is stored, a NUL-terminated string included.

public IReadOnlyDictionary<string, ReadOnlyMemory<byte>> KeyValueData { get; }

Gets the keys of the key/value data, in the order of the file.

public IReadOnlyList<string> Keys { get; }

Property value

IReadOnlyList<string>

LayerCount

Ktx2Header.cs

Gets the number of array layers, or 0 for a texture that is not an array.

public int LayerCount { get; }

Property value

int

LevelCount

Ktx2Header.cs

Gets the number of mip levels the file stores, or 0 when it stores the base level only and asks a loader to generate the others.

public int LevelCount { get; }

Property value

int

Orientation

Ktx2Header.cs

Gets the value of KTXorientation, such as rd or ruo, or null without it.

public string? Orientation { get; }

Property value

string?

PixelDepth

Ktx2Header.cs

Gets the depth of the base level, in pixels, or 0 for a texture that is not three-dimensional.

public int PixelDepth { get; }

Property value

int

PixelHeight

Ktx2Header.cs

Gets the height of the base level, in pixels, or 0 for a one-dimensional texture.

public int PixelHeight { get; }

Property value

int

PixelWidth

Ktx2Header.cs

Gets the width of the base level, in pixels.

public int PixelWidth { get; }

Property value

int

SupercompressionScheme

Ktx2Header.cs

Gets the supercompression scheme: 0 (none), 1 (BasisLZ), 2 (Zstandard) or 3 (ZLIB).

public int SupercompressionScheme { get; }

Property value

int

Gets the value of KTXswizzle, such as rrr1, or null without it.

public string? Swizzle { get; }

Property value

string?

TransferFunction

Ktx2Header.cs

Gets the transfer function of the data format descriptor (section 5.8), such as 1 (linear) or 2 (sRGB).

public int TransferFunction { get; }

Property value

int

Gets the vkFormat of the header: a value of the Vulkan VkFormat enumeration, or 0 (VK_FORMAT_UNDEFINED) for Basis Universal data.

public int VkFormat { get; }

Property value

int

Gets the value of KTXwriter, the tool that wrote the file, or null without it.

public string? Writer { get; }

Property value

string?

WriterScParams

Ktx2Header.cs

Gets the value of KTXwriterScParams, the options of the tool that wrote the file, or null without it.

public string? WriterScParams { get; }

Property value

string?

Methods

NameDescription
Equals(Ktx2Header?)Indicates whether the current object is equal to another object of the same type.
Equals(object?)Determines whether the specified object is equal to the current object.
GetHashCode()Serves as the default hash function.
ToString()Returns a string that represents the current object.

Equals overloads

Equals(Ktx2Header?)

Ktx2Header.cs

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Ktx2Header? other)
Parameters
other Ktx2Header?
An object to compare with this object.
Returns

bool true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Ktx2Header.cs

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)
Parameters
obj object?
The object to compare with the current object.
Returns

bool true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Ktx2Header.cs

Serves as the default hash function.

public override int GetHashCode()

Returns

int A hash code for the current object.

ToString()

Ktx2Header.cs

Returns a string that represents the current object.

public override string ToString()

Returns

string A string that represents the current object.