Open main menu

UESPWiki β

Mod:Shadowkey File Formats/Shadowkey Spritesheet Format

< Mod: Shadowkey File Formats

This is a description of the Global.SPR file as found in the Shadowkey data.

Basic File StructureEdit

Basic structure of the file is:

    [ Header 0x600 bytes ]
    [ Image 1 ]
    [ Image 2 ]
    [   ...   ]

There are no left over bytes at the end of the file. All file data is Little Endian.


HeaderEdit

The header is just a 0x600 byte block containing a list of 384 dwords which are the image sizes in bytes contained in the file:

    dword ImageSize[384] 

The offset for a particular file can be calculated by adding up the sizes of all images prior to the desired image and adding 0x600. An image size of 0 indicates that no data for the image exists in the file and it should be ignored. Only 253 of the 384 image slots have a non-zero image size.


Image FormatEdit

The basic image format is as follows:

    dword Width    // Pixels
    dword Height   // Pixels
    byte RawPalette[0x200]
    byte ImageData[]

Note the only way to determine the total size of the image data is to use the image size obtained in the file header and subtract the 0x204 bytes of image header data.


Palette FormatEdit

The raw palette is stored in 512 bytes (0x200) in each image header in a semi-compressed format. To get the 32-bit color for a specific palette index use the following conversion:

   byte RawPal[512]
   byte r = ((RawPal[index*2 + 1] & 0x0f) << 4) + (RawPal[index*2 + 1] & 0x0f)
   byte g = ((RawPal[index*2 + 0] & 0xf0) >> 4) + (RawPal[index*2 + 0] & 0xf0)
   byte b = ((RawPal[index*2 + 0] & 0x0f) << 4) + (RawPal[index*2 + 0] & 0x0f)


Image Data FormatEdit

The image data is encoded line by line from the bottom of the image to the top (opposite the usual direction) in the following format:

   dword Size1
   dword Size2
   byte Pixels[Size2 - Size1]

The pixel data contains palette indices starting at X coordinate of Size1 on the line (prior pixels are transparent). Also, any pixels not specified on the line after the pixel data is assumed to be transparent as well. A color value of FF00FF (violet) represents a transparent pixel within the pixel data (the exact pixel index for a transparent pixel changes from image to image).

Note that if (Size2 - Size1) is 0 or negative then no image pixel data follows (typically FF FF FF FF represents a blank transparent line).