Spr
Description
Sprite file format, this file contains a collection of images.
There are two types of images, palette images and RGBA images.
All the data is in little-endian.
This means that the number 0x0A0B0C0D is stored as:
increasing addresses →
... |
0x0D |
0x0C |
0x0B |
0x0A |
... |
Notes:
- magenta RGB(255,0,255) is usually displayed as an 'invisible' color
- images with square dimentions are recommended
Version History
- 1.0 - Base
- 1.1 - Added palette at end of file
- 2.0 - Added RGBA images
- 2.1 - Added RLE-encoding of the background in palette images
Version |
Palette images |
Palette |
RGBA images |
1.0 |
yes |
system |
no |
1.1 |
yes |
yes |
no |
2.0 |
yes |
yes |
yes |
2.1 |
yes, RLE encoded background |
yes |
yes |
Structure
v1.0
Field |
Size |
Comment |
magic |
2 (uint16) |
'SP' (0x53 0x50) |
version |
2 (uint16) |
0x100 |
nPalImages |
2 (uint16) |
number of palette images |
palImages |
variable * nPalImages |
data of the palette images |
v1.1
Field |
Size |
Comment |
magic |
2 (uint16) |
'SP' (0x53 0x50) |
version |
2 (uint16) |
0x101 |
nPalImages |
2 (uint16) |
number of palette images |
palImages |
variable * nPalImages |
data of the palette images |
palette |
1024 |
palette of 256 colors |
v2.0
Field |
Size |
Comment |
magic |
2 (uint16) |
'SP' (0x53 0x50) |
version |
2 (uint16) |
0x200 |
nPalImages |
2 (uint16) |
number of palette images |
nRgbaImages |
2 (uint16) |
number of RGBA images |
palImages |
variable * nPalImages |
data of the palette images |
rgbaImages |
variable * nRgbaImages |
data of the RGBA images |
palette |
1024 |
palette of 256 colors |
v2.1
Field |
Size |
Comment |
magic |
2 (uint16) |
'SP' (0x53 0x50) |
version |
2 (uint16) |
0x201 |
nPalImages |
2 (uint16) |
number of palette images |
nRgbaImages |
2 (uint16) |
number of RGBA images |
palImages |
variable * nPalImages |
data of the palette images (RLE-encoded background) |
rgbaImages |
variable * nRgbaImages |
data of the RGBA images |
palette |
1024 |
palette of 256 colors |
Palette image
Field |
Size |
Comment |
width |
2 (uint16) |
image width |
height |
2 (uint16) |
image height |
data |
width * height |
image data, 1 byte per pixel |
Each byte represents an index in the palette.
Palette index 0 is the 'invisible' background.
Pixels go left to right →, top to bottom ↓
Palette image (RLE-encoded background)
Field |
Size |
Comment |
width |
2 (uint16) |
image width |
height |
2 (uint16) |
image height |
compressedSize |
2 (uint16) |
size of the compressed data |
data |
compressedSize |
image data, RLE encoded for the background |
Each byte represents an index in the palette.
Palette index 0 is the 'invisible' background.
Only the background is RLE encoded.
When a 0x00 byte is parsed, the next byte indicates the number of 0x00 bytes it decompresses to. (0x00 0x00 decompresses to a single 0x00 byte)
Pixels go left to right →, top to bottom ↓
RGBA image
Field |
Size |
Comment |
width |
2 (uint16) |
image width |
height |
2 (uint16) |
image height |
data |
width * height * 4 |
image data, 4 bytes per pixel |
Pixels go left to right →, bottom to top↑
RGBA pixel
Field |
Size |
Comment |
alpha |
1 |
alpha channel/opacity |
blue |
1 |
blue intensity |
green |
1 |
green intensity |
red |
1 |
red intensity |
Palette
palette
Field |
Size |
Comment |
entries |
256 * 4 |
256 palette colors |
On version 1.0 the system palette is used instead.
palette color
Field |
Size |
Comment |
red |
1 |
intensity of red in the color |
green |
1 |
intensity of green in the color |
blue |
1 |
intensity of blue in the color |
reserved |
1 |
always 0, ignored |