![]() |
Twilight Princess
Remastered version of the GameCube game
|
The BinaryTextureImage (or BTI) format is used by Wind Waker (and several other Nintendo games) to store texture images. There are a variety of encoding methods, some of which are supported right now for decoding. This does not currently support encoding BTI files but will at some point in time. It does not load mipmaps from the file currently. More...
Classes | |
class | Palette |
The Palette simply stores the color data as loaded from the file. It does not convert the files based on the Palette type to RGBA8. More... | |
Public Types | |
enum | TextureFormats { I4 = 0x00 , I8 = 0x01 , IA4 = 0x02 , IA8 = 0x03 , RGB565 = 0x04 , RGB5A3 = 0x05 , RGBA32 = 0x06 , C4 = 0x08 , C8 = 0x09 , C14X2 = 0x0a , CMPR = 0x0e } |
ImageFormat specifies how the data within the image is encoded. Included is a chart of how many bits per pixel there are, the width/height of each block, how many bytes long the actual block is, and a description of the type of data stored. More... | |
enum | WrapModes { ClampToEdge = 0 , Repeat = 1 , MirroredRepeat = 2 } |
Defines how textures handle going out of [0..1] range for texcoords. More... | |
enum | PaletteFormats { IA8 = 0x00 , RGB565 = 0x01 , RGB5A3 = 0x02 } |
PaletteFormat specifies how the data within the palette is stored. An image uses a single palette (except CMPR which defines its own mini-palettes within the Image data). Only C4, C8, and C14X2 use palettes. For all other formats the type and count is zero. More... | |
enum | FilterMode { Nearest = 0x0 , Linear = 0x1 , NearestMipmapNearest = 0x2 , NearestMipmapLinear = 0x3 , LinearMipmapNearest = 0x4 , LinearMipmapLinear = 0x5 } |
FilterMode specifies what type of filtering the file should use for min/mag. More... | |
Public Member Functions | |
BinaryTextureImage () | |
BinaryTextureImage (string name) | |
void | Load (EndianBinaryReader stream, long headerStart, int imageIndex=0) |
Load a BinaryTextureImage from a stream. | |
void | ReplaceHeaderInfo (BinaryTextureImage other) |
void | DetectAndSetFittingFormat () |
void | SaveImageToDisk (string outputFile) |
Texture2D | SkiaToTexture () |
void | WriteHeader (EndianBinaryWriter writer) |
Loads image data from disk into a byte array. | |
Static Public Member Functions | |
static byte[] | DecodeData (EndianBinaryReader stream, uint width, uint height, TextureFormats format) |
Public Attributes | |
short | unknown2 = 0 |
byte | unknown3 = 0 |
Properties | |
string | Name [get, set] |
TextureFormats | Format [get, set] |
byte | AlphaSetting [get, set] |
ushort | Width [get, private set] |
ushort | Height [get, private set] |
WrapModes | WrapS [get, set] |
WrapModes | WrapT [get, set] |
bool | PalettesEnabled [get, set] |
PaletteFormats | PaletteFormat [get, set] |
ushort | PaletteCount [get, set] |
int | EmbeddedPaletteOffset [get, private set] |
FilterMode | MinFilter [get, set] |
FilterMode | MagFilter [get, set] |
sbyte | MinLOD [get, set] |
sbyte | MagLOD [get, set] |
byte | MipMapCount [get, private set] |
short | LodBias [get, set] |
byte[] | RGBAImageData [get, set] |
Private Member Functions | |
Tuple< byte[], ushort[]> | EncodeC4 () |
Tuple< byte[], ushort[]> | EncodeC8 () |
void | EncodeColor (Color32 col, List< ushort > rawColorData, Dictionary< Color32, byte > pixelColorIndexes) |
Static Private Member Functions | |
static byte[] | DecodeData (EndianBinaryReader stream, uint width, uint height, TextureFormats format, Palette imagePalette, PaletteFormats paletteFormat) |
static byte[] | DecodeRgba32 (EndianBinaryReader stream, uint width, uint height) |
static byte[] | DecodeC4 (EndianBinaryReader stream, uint width, uint height, Palette imagePalette, PaletteFormats paletteFormat) |
static byte[] | DecodeC8 (EndianBinaryReader stream, uint width, uint height, Palette imagePalette, PaletteFormats paletteFormat) |
static byte[] | DecodeRgb565 (EndianBinaryReader stream, uint width, uint height) |
static byte[] | DecodeCmpr (EndianBinaryReader stream, uint width, uint height) |
static byte[] | DecodeCmprSubBlock (EndianBinaryReader stream) |
static void | Swap (ref byte b1, ref byte b2) |
static ushort | Read16Swap (byte[] data, uint offset) |
static uint | Read32Swap (byte[] data, uint offset) |
static byte | S3TC1ReverseByte (byte b) |
static byte[] | DecodeIA8 (EndianBinaryReader stream, uint width, uint height) |
static byte[] | DecodeIA4 (EndianBinaryReader stream, uint width, uint height) |
static byte[] | DecodeI4 (EndianBinaryReader stream, uint width, uint height) |
static byte[] | DecodeI8 (EndianBinaryReader stream, uint width, uint height) |
static byte[] | DecodeRgb5A3 (EndianBinaryReader stream, uint width, uint height) |
static void | UnpackPixelFromPalette (int paletteIndex, ref byte[] dest, int offset, byte[] paletteData, PaletteFormats format) |
static void | RGB565ToRGBA8 (ushort sourcePixel, ref byte[] dest, int destOffset) |
Convert a RGB565 encoded pixel (two bytes in length) to a RGBA (4 byte in length) pixel. | |
static void | RGB5A3ToRGBA8 (ushort sourcePixel, ref byte[] dest, int destOffset) |
Convert a RGB5A3 encoded pixel (two bytes in length) to an RGBA (4 byte in length) pixel. | |
Private Attributes | |
Palette | m_imagePalette |
byte[] | m_rgbaImageData |
The BinaryTextureImage (or BTI) format is used by Wind Waker (and several other Nintendo games) to store texture images. There are a variety of encoding methods, some of which are supported right now for decoding. This does not currently support encoding BTI files but will at some point in time. It does not load mipmaps from the file currently.
Image data can be retrieved by calling GetData() which will return an ARGB array of bytes containing the information. For files without alpha data their values will be set to 0xFF.
BTI files are stored both individually on disk and embedded within other file formats.
ImageFormat specifies how the data within the image is encoded. Included is a chart of how many bits per pixel there are, the width/height of each block, how many bytes long the actual block is, and a description of the type of data stored.
Enumerator | |
---|---|
I4 | |
I8 | |
IA4 | |
IA8 | |
RGB565 | |
RGB5A3 | |
RGBA32 | |
C4 | |
C8 | |
C14X2 | |
CMPR |
BinaryTextureImage.BinaryTextureImage | ( | ) |
BinaryTextureImage.BinaryTextureImage | ( | string | name | ) |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
static |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
void BinaryTextureImage.DetectAndSetFittingFormat | ( | ) |
|
private |
|
private |
|
private |
void BinaryTextureImage.Load | ( | EndianBinaryReader | stream, |
long | headerStart, | ||
int | imageIndex = 0 ) |
Load a BinaryTextureImage from a stream.
stream | |
headerStart | |
imageIndex | Optional additional offset used by J3D models. Multiplied by 0x20. |
|
staticprivate |
|
staticprivate |
void BinaryTextureImage.ReplaceHeaderInfo | ( | BinaryTextureImage | other | ) |
|
staticprivate |
Convert a RGB565 encoded pixel (two bytes in length) to a RGBA (4 byte in length) pixel.
sourcePixel | RGB565 encoded pixel. |
dest | Destination array for RGBA pixel. |
destOffset | Offset into destination array to write RGBA pixel. |
|
staticprivate |
Convert a RGB5A3 encoded pixel (two bytes in length) to an RGBA (4 byte in length) pixel.
sourcePixel | RGB5A3 encoded pixel. |
dest | Destination array for RGBA pixel. |
destOffset | Offset into destination array to write RGBA pixel. |
|
staticprivate |
void BinaryTextureImage.SaveImageToDisk | ( | string | outputFile | ) |
Texture2D BinaryTextureImage.SkiaToTexture | ( | ) |
|
staticprivate |
|
staticprivate |
void BinaryTextureImage.WriteHeader | ( | EndianBinaryWriter | writer | ) |
Loads image data from disk into a byte array.
|
private |
|
private |
short BinaryTextureImage.unknown2 = 0 |
byte BinaryTextureImage.unknown3 = 0 |
|
getset |
|
getprivate set |
|
getset |
|
getprivate set |
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
getprivate set |
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
getprivate set |
|
getset |
|
getset |