KMG is a standard graphics API independent container file format for storing textures used by GPUs.
All these issues have been addressed by KMG file format.
Proposal draft.
Byte[12] Identifier UInt32 Endianness UInt32 Target UInt32 Format UInt32 SwizzleRed UInt32 SwizzleGreen UInt32 SwizzleBlue Uint32 SwizzleAlpha UInt32 PixelWidth UInt32 PixelHeight UInt32 PixelDepth UInt32 Layers UInt32 Levels UInt32 Faces UInt32 GenerateMipmaps UInt32 BaseLevel UInt32 MaxLevel for each Layer in Layers for each Level in Levels for each Face in Faces for each Depth in PixelDepth for each row or RowOfBlocks in PixelHeight for each pixel or BlockOfPixels in PixelWidth Byte data[format-specific-number-of-bytes] end end end end end end
The file identifier is a unique set of bytes that will differentiate the file from other types of files. It consists of 12 bytes, as follows:
Byte[12] FileIdentifier = { 0xAB, 0x4B, 0x4D, 0x4A, 0x31, 0x30, 0x30, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A }
This can also be expressed using C-style character definitions as:
Byte[12] FileIdentifier = { '«', 'K', 'M', 'G', '1', '0', '0', '»', '\r', '\n', '\x1A', '\n' }
The rationale behind the choice values in the identifier is based on the rationale for the identifier in the PNG specification. This identifier both identifies the file as a KMG file and provides for immediate detection of common file-transfer problems.
Endianness
contains the number 0x04030201
written as a 32 bit integer. If the file is little endian then this is represented as the bytes 0x01 0x02 0x03 0x04
. If the file is big endian then this is represented as the bytes 0x04 0x03 0x02 0x01
. When reading endianness as a 32 bit integer produces the value 0x04030201 then the endianness of the file matches the endianness of the program that is reading the file and no conversion is necessary. When reading endianness as a 32 bit integer produces the value 0x01020304
then the endianness of the file is opposite the endianness of the program that is reading the file, and in that case the program reading the file must endian convert all header bytes to the endianness of the program (i.e. a little endian program must convert from big endian, and a big endian program must convert to little endian).
Target
must be one of the following values:
Name | Value | Description |
---|---|---|
TARGET_1D | 0 | Images in this texture all are 1-dimensional. They have width, but no height or depth |
TARGET_1D_ARRAY | 1 | Images in this texture all are 1-dimensional. However, it contains multiple sets of 1-dimensional images, all within one texture. The array length is part of the texture's size. |
TARGET_2D | 2 | Images in this texture all are 1-dimensional. However, it contains multiple sets of 1-dimensional images, all within one texture. The array length is part of the texture's size. |
TARGET_2D_ARRAY | 3 | Images in this texture all are 1-dimensional. However, it contains multiple sets of 1-dimensional images, all within one texture. The array length is part of the texture's size. |
TARGET_3D | 4 | Images in this texture all are 3-dimensional. They have width, height, and depth. |
TARGET_BUFFER | 5 | The image in this texture (only one image. No mipmapping) is 1-dimensional. The storage for this data comes from a Buffer Object. |
TARGET_CUBE | 6 | There are exactly 6 distinct sets of 2D images, all of the same size. They act as 6 faces of a cube. |
TARGET_CUBE_ARRAY | 7 | Images in this texture are all cube maps. It contains multiple sets of cube maps, all within one texture. The array length * 6 (number of cube faces) is part of the texture size. |
TARGET_RECTANGLE | 8 | The image in this texture (only one image. No mipmapping) is 2-dimensional. Texture coordinates used for these textures are not normalized. |
Format
must be one of the following values:
Name | Value | Comment | Reference |
---|---|---|---|
FORMAT_RG4_UNORM | 1 | ||
FORMAT_RG4_USCALED | 2 | ||
FORMAT_RGBA4_UNORM | 3 | ||
FORMAT_RGBA4_USCALED | 4 | ||
FORMAT_R5G6B5_UNORM | 5 | ||
FORMAT_R5G6B5_USCALED | 6 | ||
FORMAT_RGB5A1_UNORM | 7 | ||
FORMAT_RGB5A1_USCALED | 8 | ||
FORMAT_R8_UNORM | 9 | ||
FORMAT_R8_SNORM | 10 | ||
FORMAT_R8_USCALED | 11 | ||
FORMAT_R8_SSCALED | 12 | ||
FORMAT_R8_UINT | 13 | ||
FORMAT_R8_SINT | 14 | ||
FORMAT_R8_SRGB | 15 | ||
FORMAT_RG8_UNORM | 16 | ||
FORMAT_RG8_SNORM | 17 | ||
FORMAT_RG8_USCALED | 18 | ||
FORMAT_R8_SSCALED | 19 | ||
FORMAT_RG8_UINT | 20 | ||
FORMAT_RG8_SINT | 21 | ||
FORMAT_RG8_SRGB | 22 | ||
FORMAT_RGB8_UNORM | 23 | ||
FORMAT_RGB8_SNORM | 24 | ||
FORMAT_RGB8_USCALED | 25 | ||
FORMAT_RGB8_SSCALED | 26 | ||
FORMAT_RGB8_UINT | 27 | ||
FORMAT_RGB8_SINT | 28 | ||
FORMAT_RGB8_SRGB | 29 | ||
FORMAT_RGBA8_UNORM | 30 | ||
FORMAT_RGBA8_SNORM | 31 | ||
FORMAT_RGBA8_USCALED | 32 | ||
FORMAT_RGBA8_SSCALED | 33 | ||
FORMAT_RGBA8_UINT | 34 | ||
FORMAT_RGBA8_SINT | 35 | ||
FORMAT_RGBA8_SRGB | 36 | ||
FORMAT_RGB10A2_UNORM | 37 | ||
FORMAT_RGB10A2_SNORM | 38 | ||
FORMAT_RGB10A2_USCALED | 39 | ||
FORMAT_RGB10A2_SSCALED | 40 | ||
FORMAT_RGB10A2_UINT | 41 | ||
FORMAT_RGB10A2_SINT | 42 | ||
FORMAT_R16_UNORM | 43 | ||
FORMAT_R16_SNORM | 44 | ||
FORMAT_R16_USCALED | 45 | ||
FORMAT_R16_SSCALED | 46 | ||
FORMAT_R16_UINT | 47 | ||
FORMAT_R16_SINT | 48 | ||
FORMAT_R16_SFLOAT | 49 | ||
FORMAT_RG16_UNORM | 50 | ||
FORMAT_RG16_SNORM | 51 | ||
FORMAT_RG16_USCALED | 52 | ||
FORMAT_RG16_SSCALED | 53 | ||
FORMAT_RG16_UINT | 54 | ||
FORMAT_RG16_SINT | 55 | ||
FORMAT_RG16_SFLOAT | 56 | ||
FORMAT_RGB16_UNORM | 57 | ||
FORMAT_RGB16_SNORM | 58 | ||
FORMAT_RGB16_USCALED | 59 | ||
FORMAT_RGB16_SSCALED | 60 | ||
FORMAT_RGB16_UINT | 61 | ||
FORMAT_RGB16_SINT | 62 | ||
FORMAT_RGB16_SFLOAT | 63 | ||
FORMAT_RGBA16_UNORM | 64 | ||
FORMAT_RGBA16_SNORM | 65 | ||
FORMAT_RGBA16_USCALED | 66 | ||
FORMAT_RGBA16_SSCALED | 67 | ||
FORMAT_RGBA16_UINT | 68 | ||
FORMAT_RGBA16_SINT | 69 | ||
FORMAT_RGBA16_SFLOAT | 70 | ||
FORMAT_R32_UINT | 71 | ||
FORMAT_R32_SINT | 72 | ||
FORMAT_R32_SFLOAT | 73 | ||
FORMAT_RG32_UINT | 74 | ||
FORMAT_RG32_SINT | 75 | ||
FORMAT_RG32_SFLOAT | 76 | ||
FORMAT_RGB32_UINT | 77 | ||
FORMAT_RGB32_SINT | 78 | ||
FORMAT_RGB32_SFLOAT | 79 | ||
FORMAT_RGBA32_UINT | 80 | ||
FORMAT_RGBA32_SINT | 81 | ||
FORMAT_RGBA32_SFLOAT | 82 | ||
FORMAT_R64_SFLOAT | 83 | ||
FORMAT_RG64_SFLOAT | 84 | ||
FORMAT_RGB64_SFLOAT | 85 | ||
FORMAT_RGBA64_SFLOAT | 86 | ||
FORMAT_R64_SFLOAT | 83 | ||
FORMAT_RG64_SFLOAT | 84 | ||
FORMAT_RGB64_SFLOAT | 85 | ||
FORMAT_RGBA64_SFLOAT | 86 | ||
FORMAT_RG11B10_UFLOAT | 87 | ||
FORMAT_RGB9E5_UFLOAT | 88 | ||
FORMAT_D16_UNORM | 89 | ||
FORMAT_D24_UNORM | 90 | ||
FORMAT_D32_SFLOAT | 91 | ||
FORMAT_S8_UINT | 92 | ||
FORMAT_D16_UNORM_S8_UINT | 93 | ||
FORMAT_D24_UNORM_S8_UINT | 94 | ||
FORMAT_D32_SFLOAT_S8_UINT | 95 | ||
FORMAT_RGB_DXT1_UNORM | 96 | [S3TC] | |
FORMAT_RGB_DXT1_SRGB | 97 | [S3TC_SRGB] | |
FORMAT_RGBA_DXT1_UNORM | 98 | [S3TC] | |
FORMAT_RGBA_DXT1_SRGB | 99 | [S3TC_SRGB] | |
FORMAT_RGBA_DXT3_UNORM | 100 | [S3TC] | |
FORMAT_RGBA_DXT3_SRGB | 101 | [S3TC_SRGB] | |
FORMAT_RGBA_DXT5_UNORM | 102 | [S3TC] | |
FORMAT_RGBA_DXT5_SRGB | 103 | [S3TC_SRGB] | |
FORMAT_R_ATI1N_UNORM | 104 | [RGTC] | |
FORMAT_R_ATI1N_SNORM | 105 | [RGTC] | |
FORMAT_RG_ATI2N_UNORM | 106 | [RGTC] | |
FORMAT_RG_ATI2N_SNORM | 107 | [RGTC] | |
FORMAT_RGB_BP_UFLOAT | 108 | [BPTC] | |
FORMAT_RGB_BP_SFLOAT | 109 | [BPTC] | |
FORMAT_RGBA_BP_UNORM | 110 | [BPTC] | |
FORMAT_RGBA_BP_SRGB | 111 | [BPTC] | |
FORMAT_RGB_ETC2_UNORM | 112 | [ETC2] | |
FORMAT_RGB_ETC2_SRGB | 113 | [ETC2] | |
FORMAT_RGBA_ETC2_A1_UNORM | 114 | [ETC2] | |
FORMAT_RGBA_ETC2_A1_SRGB | 115 | [ETC2] | |
FORMAT_RGBA_ETC2_UNORM | 116 | [ETC2] | |
FORMAT_RGBA_ETC2_SRGB | 117 | [ETC2] | |
FORMAT_R_EAC_UNORM | 118 | [ETC2] | |
FORMAT_R_EAC_SNORM | 119 | [ETC2] | |
FORMAT_RG_EAC_UNORM | 120 | [ETC2] | |
FORMAT_RG_EAC_SNORM | 121 | [ETC2] | |
FORMAT_RGBA_ASTC_4X4_UNORM | 122 | [ASTC] | |
FORMAT_RGBA_ASTC_4X4_SRGB | 123 | [ASTC] | |
FORMAT_RGBA_ASTC_5X4_UNORM | 124 | [ASTC] | |
FORMAT_RGBA_ASTC_5X4_SRGB | 125 | [ASTC] | |
FORMAT_RGBA_ASTC_5X5_UNORM | 126 | [ASTC] | |
FORMAT_RGBA_ASTC_5X5_SRGB | 127 | [ASTC] | |
FORMAT_RGBA_ASTC_6X5_UNORM | 128 | [ASTC] | |
FORMAT_RGBA_ASTC_6X5_SRGB | 129 | [ASTC] | |
FORMAT_RGBA_ASTC_6X6_UNORM | 130 | [ASTC] | |
FORMAT_RGBA_ASTC_6X6_SRGB | 131 | [ASTC] | |
FORMAT_RGBA_ASTC_8X5_UNORM | 132 | [ASTC] | |
FORMAT_RGBA_ASTC_8X5_SRGB | 133 | [ASTC] | |
FORMAT_RGBA_ASTC_8X6_UNORM | 134 | [ASTC] | |
FORMAT_RGBA_ASTC_8X6_SRGB | 135 | [ASTC] | |
FORMAT_RGBA_ASTC_8X8_UNORM | 136 | [ASTC] | |
FORMAT_RGBA_ASTC_8X8_SRGB | 137 | [ASTC] | |
FORMAT_RGBA_ASTC_10X5_UNORM | 138 | [ASTC] | |
FORMAT_RGBA_ASTC_10X5_SRGB | 139 | [ASTC] | |
FORMAT_RGBA_ASTC_10X6_UNORM | 140 | [ASTC] | |
FORMAT_RGBA_ASTC_10X6_SRGB | 141 | [ASTC] | |
FORMAT_RGBA_ASTC_10X8_UNORM | 142 | [ASTC] | |
FORMAT_RGBA_ASTC_10X8_SRGB | 143 | [ASTC] | |
FORMAT_RGBA_ASTC_10X10_UNORM | 144 | [ASTC] | |
FORMAT_RGBA_ASTC_10X10_SRGB | 145 | [ASTC] | |
FORMAT_RGBA_ASTC_12X10_UNORM | 146 | [ASTC] | |
FORMAT_RGBA_ASTC_12X10_SRGB | 147 | [ASTC] | |
FORMAT_RGBA_ASTC_12X12_UNORM | 148 | [ASTC] | |
FORMAT_RGBA_ASTC_12X12_SRGB | 149 | [ASTC] | |
FORMAT_BGRA4_UNORM | 150 | ||
FORMAT_BGRA4_USCALED | 151 | ||
FORMAT_B5G6R5_UNORM | 152 | ||
FORMAT_B5G6R5_USCALED | 153 | ||
FORMAT_BGR5A1_UNORM | 154 | ||
FORMAT_BGR5A1_USCALED | 155 | ||
FORMAT_BGR8_UNORM | 156 | ||
FORMAT_BGR8_SNORM | 157 | ||
FORMAT_BGR8_USCALED | 158 | ||
FORMAT_BGR8_SSCALED | 159 | ||
FORMAT_BGR8_UINT | 160 | ||
FORMAT_BGR8_SINT | 161 | ||
FORMAT_BGR8_SRGB | 162 | ||
FORMAT_BGRA8_UNORM | 163 | ||
FORMAT_BGRA8_SNORM | 164 | ||
FORMAT_BGRA8_USCALED | 165 | ||
FORMAT_BGRA8_SSCALED | 166 | ||
FORMAT_BGRA8_UINT | 167 | ||
FORMAT_BGRA8_SINT | 168 | ||
FORMAT_BGRA8_SRGB | 169 | ||
FORMAT_BGR10A2_UNORM | 170 | ||
FORMAT_BGR10A2_SNORM | 171 | ||
FORMAT_BGR10A2_USCALED | 172 | ||
FORMAT_BGR10A2_SSCALED | 173 | ||
FORMAT_BGR10A2_UINT | 174 | ||
FORMAT_BGR10A2_SINT | 175 | ||
FORMAT_RG3B2_UNORM | 176 | ||
FORMAT_BGRX8_UNORM | 177 | ||
FORMAT_BGRX8_SRGB | 178 | ||
FORMAT_L8_UNORM | 179 | ||
FORMAT_A8_UNORM | 180 | ||
FORMAT_LA8_UNORM | 181 | ||
FORMAT_L16_UNORM | 182 | ||
FORMAT_A16_UNORM | 183 | ||
FORMAT_LA16_UNORM | 184 | ||
FORMAT_RGB_PVRTC1_8X8_UNORM | 185 | 4 bits per pixel format | [PVRTC1] |
FORMAT_RGB_PVRTC1_8X8_SRGB | 186 | 4 bits per pixel format | [PVRTC1_SRGB] |
FORMAT_RGB_PVRTC1_16X8_UNORM | 187 | 2 bits per pixel format | [PVRTC1] |
FORMAT_RGB_PVRTC1_16X8_SRGB | 188 | 2 bits per pixel format | [PVRTC1_SRGB] |
FORMAT_RGBA_PVRTC1_8X8_UNORM | 189 | 4 bits per pixel format | [PVRTC1] |
FORMAT_RGBA_PVRTC1_8X8_SRGB | 190 | 4 bits per pixel format | [PVRTC1_SRGB] |
FORMAT_RGBA_PVRTC1_16X8_UNORM | 191 | 2 bits per pixel format | [PVRTC1] |
FORMAT_RGBA_PVRTC1_16X8_SRGB | 192 | 2 bits per pixel format | [PVRTC1_SRGB] |
FORMAT_RGBA_PVRTC2_4X4_UNORM | 193 | 4 bits per pixel format | [PVRTC2] |
FORMAT_RGBA_PVRTC2_4X4_SRGB | 194 | 4 bits per pixel format | [PVRTC2_SRGB] |
FORMAT_RGBA_PVRTC2_8X4_UNORM | 195 | 2 bits per pixel format | [PVRTC2] |
FORMAT_RGBA_PVRTC2_8X4_SRGB | 196 | 2 bits per pixel format | [PVRTC2_SRGB] |
FORMAT_RGB_ETC_UNORM | 197 | [ETC1] | |
FORMAT_RGB_ATC_UNORM | 198 | [ATC] | |
FORMAT_RGBA_ATC_EXPLICIT_UNORM | 199 | [ATC] | |
FORMAT_RGBA_ATC_INTERPOLATED_UNORM | 200 | [ATC] |
The per block storage for compressed formats is described in reference documents.
The channels exposed by the formats are exposed using the following letters:
R
: Red channel.G
: Green channel.B
: Blue channel.A
: Alpha channel.D
: Depth channel.S
: Stencil channel.L
: Luminance channel. When converted to RGB, the channel value is copied to each RGB component.X
: Memory padding, eg: BGR 8 bits per channel stored in 32 bits where 8 bits are meant to be ignored.The order of the components in the formats follows the order of the component in memory.
The following postfixs are used to describ properties of the format:
UNORM
: Unsigned integer data sampled with border values clamped as unsigned normalized floatSNORM
: Signed integer data sampled with border values clamped as signed normalized floatUSCALE
: Unsigned integer data sampled with border values clamped as unsigned scaled floatSSCALE
: Signed integer data sampled with border values clamped as signed scaled floatUINT
: Unsigned integer data sampled as unsigned integerSINT
: Signed integer data sampled as signed integerUFLOAT
: Floating point value without signed bit dataSFLOAT
: Floating point value dataSRGB
: Standardized non-linear unsigned integer data with roughly a 2.2 gamma correction data (IEC 61966-2-1) sampled with border values clamped as unsigned normalized float
Swizzle is a mechanism to swizzle the components of a texture before they are applied as they are returned to the shader.
SwizzleRed
, SwizzleGreen
, SwizzleBlue
and SwizzleAlpha
must take one of the following values:
Name | Value |
---|---|
SWIZZLE_RED | 0 |
SWIZZLE_GREEN | 1 |
SWIZZLE_BLUE | 2 |
SWIZZLE_ALPHA | 3 |
SWIZZLE_ZERO | 4 |
SWIZZLE_ONE | 5 |
The first swizzle parameter affects the first component of Cs as:
if (SwizzleRed == SWIZZLE_RED) { TexelDestination[0] = TexelSource[0]; } else if (SwizzleRed == SWIZZLE_GREEN) { TexelDestination[0] = TexelSource[1]; } else if (SwizzleRed == SWIZZLE_BLUE) { TexelDestination[0] = TexelSource[2]; } else if (SwizzleRed == SWIZZLE_ALPHA) { TexelDestination[0] = TexelSource[3]; } else if (SwizzleRed == SWIZZLE_ZERO) { TexelDestination[0] = 0; } else if (SwizzleRed == SWIZZLE_ONE) { TexelDestination[0] = 1; // float or int depending on texture component type } and similarly for the other components.
The size of the texture image for level 0, in pixels. No rounding to block sizes should be applied for block compressed textures.
For 1D textures PixelHeight
and PixelDepth
must be 1.
For 2D and cube textures PixelDepth
must be 1.
Layers
specifies the number of layers in a texture array. The minimum value is 1.
Levels
must equal 1 for non-mipmapped textures. For
mipmapped textures, it equals the number of mipmaps. Mipmaps are stored
in order from largest size to smallest size. The first mipmap level is
always level 0. A KMG file does not need to contain a complete mipmap
pyramid. If Levels
equals 0, it indicates that a full
mipmap pyramid should be generated from level 0 at load time (this is
usually not allowed for compressed formats).
Faces
specifies the number of cubemap faces. For cubemaps and cubemap arrays this should be 6.
For non cubemaps this should be 1. Cube map faces are stored in the order: +X, -X, +Y, -Y, +Z, -Z.
Mipmap generation replaces texel image levels baselevel + 1
through q
with images derived from the baselevel
image, regardless of their previous contents. All other mimap images, including the baselevel + 1
image, are left unchanged by this computation.
The internal formats of the derived mipmap images all match those of the baselevel
image. The contents of the derived images are computed by repeated, filtered reduction of the baselevel + 1
image. For one- and two-dimensional array and cube map array textures, each layer is filtered independently.
Name | Value |
---|---|
FILTER_NONE | 0 |
FILTER_NEAREST | 1 |
FILTER_LINEAR | 2 |
If the texture format is compressed, GenerateMipmaps
must be FILTER_NONE
.
Specifies the index of the lowest defined mipmap level.
The minimum value is 0. The maximum value is log2(max(width, height, depth)) + 1
.
BaseLevel
must be lower or equal to MaxLevel
.
Sets the index of the highest defined mipmap level. This is an integer value.
The minimum value is 0. The maximum value is log2(max(width, height, depth)) + 1
.
BaseLevel
must be lower or equal to MaxLevel
.
The unpack alignment is 4. I.e. uncompressed pixel data is packed according to the rules described in section 8.4.4.1 of the OpenGL 4.4 specification [OPENGL44] for a GL_UNPACK_ALIGNMENT of 4.
Values listed in tables referred to in the OpenGL 4.4 specification [OPENGL44] may be supplemented by extensions. The references are given as examples and do not imply that all of those texture types can be loaded in OpenGL ES or earlier versions of OpenGL.
Texture data in a KMG file are arranged so that the first pixel in the data stream for each face and/or array element is closest to the origin of the texture coordinate system. In OpenGL that origin is conventionally described as being at the lower left, but this convention is not shared by all image file formats and content creation tools, so there is abundant room for confusion.
The desired texture axis orientation is often predetermined by, e.g. a content creation tool's or existing application's use of the image. Therefore it is strongly recommended that tools for generating KMG files clearly describe their behaviour, and provide an option to specify the texture axis origin and orientation relative to the logical orientation of the source image. At minimum they should provide a choice between top-left and bottom-left as origin for 2D source images, with the positive S axis pointing right. Where possible, the preferred default is to use the logical upper-left corner of the image as the texture origin. Note that this is contrary to the standard interpretation of GL texture coordinates. However, the majority of texture compression tools use this convention.
As an aid to writing image manipulation tools and viewers, the logical orientation of the data in a KMG file may be indicated in the file's key/value metadata. Note that this metadata affects only the logical interpretation of the data, has no effect on the mapping from pixels in the file byte stream to texture coordinates. The recommended key to use is:
It is recommended that viewing and editing tools support at least the following values:
where
Although other orientations can be represented, it is recommended that tools that create KMG files use only the values listed above as other values may not be widely supported by other tools.
// HEADER 0xAB, 0x4B, 0x54, 0x58, // first four bytes of Byte[12] identifier 0x20, 0x32, 0x30, 0xBB, // next four bytes of Byte[12] identifier 0x0D, 0x0A, 0x1A, 0x0A. // final four bytes of Byte[12] identifier 0x04, 0x03, 0x02, 0x01, // Byte[4] endianness (Big endian in this case) 0x00, 0x00, 0x00, 0x02, // UInt32 Target = TARGET_2D 0x00, 0x00, 0x00, 0x24, // UInt32 Format = FORMAT_RGBA8_SRGB 0x00, 0x00, 0x00, 0x00, // UInt32 SwizzleRed = SWIZZLE_RED 0x00, 0x00, 0x8D, 0x64, // UInt32 SwizzleGreen = SWIZZLE_GREEN 0x00, 0x00, 0x19, 0x07, // UInt32 SwizzleBlue = SWIZZLE_BLUE 0x00, 0x00, 0x19, 0x07, // UInt32 SwizzleAlpha = SWIZZLE_ALPHA 0x00, 0x00, 0x00, 0x20, // UInt32 PixelWidth = 32 0x00, 0x00, 0x00, 0x20, // UInt32 PixelHeight = 32 0x00, 0x00, 0x00, 0x00, // UInt32 PixelDepth = 1 0x00, 0x00, 0x00, 0x00, // UInt32 Layers = 1 0x00, 0x00, 0x00, 0x01, // UInt32 Faces = 1 0x00, 0x00, 0x00, 0x01, // UInt32 Levels = 1 0x00, 0x00, 0x00, 0x00, // UInt32 GenerateMipmaps = FILTER_NONE // TEXTURE DATA 0xD8, 0xD8, 0xD8, 0xDA, // Byte[512] RGBA8 texture data... ...
Permission is expressly granted to IANA to copy this section as necessary for managing the MIME types registry.
Type name: Image
Subtype name: kmg
Required parameters: none
Optional parameters: none
Encoding considerations: binary
Security considerations:
The kmg type is a binary data stream which contains no executable code that could disrupt a client processor. There is no provision in the type specification that would allow authors to insert executable code that would present any security risk to a client machine.
Because every item's length is available at its beginning, there is robust defense against corrupted or fraudulent data that might overflow a decoder's buffer. Also the signature bytes provide early detection of common file transmission errors.
The kmg type may contain texture data compressed using OpenGL standard or vendor-specific schemes. These compression schemes are designed so small blocks of data (typically around 64 bits) can be decompressed in real time into a small block of pixels (typically 4x4) during texel fetch. In such schemes it is not possible for a small amount of data to expand enormously because the level of compression is limited; the compressed size is related directly to the number of pixels in the uncompressed image and not to the content of the data.
The kmg type does not provide encryption of the data payload. Users or applications wishing or needing to keep their images confidential must overlay their own encryption on the kmg data during transmission.
Interoperability considerations:
The kmg type includes a field identifying the endianness of the machine which created the data. Applications reading the data are expected to check this field and convert the endianness, if necessary. The texture data payload may be compressed using an OpenGL-vendor-specific scheme. In this case, only devices or applications having a matching decompressor will be able to display the data. The compression scheme is identified in the kmg data so applications can quickly reject data using unsupported schemes.
This specification is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. It or any components may not be reproduced, republished, distributed, transmitted, displayed, broadcast or otherwise exploited in any manner without the express prior written permission of Khronos Group. You may use this specification for implementing the functionality therein, without altering or removing any trademark, copyright or other notice from the specification, but the receipt or possession of this specification does not convey any rights to reproduce, disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, in whole or in part.
Khronos Group grants express permission to any current Promoter, Contributor or Adopter member of Khronos to copy and redistribute UNMODIFIED versions of this specification in any fashion, provided that NO CHARGE is made for the specification and the latest available update of the specification for any version of the API is used whenever possible. Such distributed specification may be re-formatted AS LONG AS the contents of the specification are not changed in any way. The specification may be incorporated into a product that is sold as long as such product includes significant independent work developed by the seller. A link to the current version of this specification on the Khronos Group web-site should be included whenever possible with specification distributions.
Khronos Group also grants express permission to the Internet Assigned Numbers Authority (IANA) to make archival copies of this specification, and to redistribute such a copy in the event that the link to the specification on the Khronos Group web-site becomes inoperative and it is determined that it will not be repaired. Outside of this exceptional circumstance, IANA should refer to the specification by providing a link to the current version on the Khronos Group web-site.
Khronos Group makes no, and expressly disclaims any, representations or warranties, express or implied, regarding this specification, including, without limitation, any implied warranties of merchantability or fitness for a particular purpose or non-infringement of any intellectual property. Khronos Group makes no, and expressly disclaims any, warranties, express or implied, regarding the correctness, accuracy, completeness, timeliness, and reliability of the specification. Under no circumstances will the Khronos Group, or any of its Promoters, Contributors or Members or their respective partners, officers, directors, employees, agents or representatives be liable for any damages, whether direct, indirect, special or consequential damages for lost revenues, lost profits, or otherwise, arising from or in connection with these materials.
Khronos, OpenKODE, OpenKOGS, OpenVG, OpenMAX, OpenSL ES and OpenWF are trademarks of the Khronos Group Inc. COLLADA is a trademark of Sony Computer Entertainment Inc. used by permission by Khronos. OpenGL and OpenML are registered trademarks and the OpenGL ES logo is a trademark of Silicon Graphics Inc. used by permission by Khronos. All other product names, trademarks, and/or company names are used solely for identification and belong to their respective owners.