Steve's Simple Image Format
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Steven vanZyl bfabcf997d Various improvements and documantation 1 week ago
samples Various improvements and documantation 1 week ago
src Various improvements and documantation 1 week ago
.gitignore Began a web-frontend 1 month ago
Cargo.toml Feature Flags and Viewer 1 week ago
LICENSE Feature Flags and Viewer 1 week ago
README.md Spec change and tweaks 1 month ago
logo.png Various improvements and documantation 1 week ago

README.md

Steve’s Simple Image Format

This is a simple graphical image format that I created as a challenge for myself: To design and create an image format, with decoder, in a day.

I chose Rust simply because I like it and thought it was suitable for this project. Additionally I intend to write a simple web decoder which possibly will use WebAssembly so Rust is quite suited.

Building

cargo build

Specification

Header

Every file begins with the header which is exactly 7 bytes long and is composed of:

  • 2 byte magic number. In hex it’s AE AE.
  • 1 byte sequential version number.
  • 2 byte width of the image.
  • 2 byte height of the image.

The magic number identifies this file as a SSIF file regardless of the file extension or any other interference.

The version number is used for compatibility purposes with other versions of the format.

The width and height are conviences for developers so that the format can easily be read into a fixed sized buffer with the size known beforehand. This does however limit the image to a total of 2^32 bytes.

Format and Compression

Past the header is the actual file data, which can be broken up into 3-byte segments. These 2 bytes contain:

  • 2 bytes of color data.
  • 1 byte length of the color run.

The length of the data section must be a mutiple of 3. Any additional bytes will be ignored.

The color data itself is contained within two bytes representing RGBA in 4-bits each in exactly that order. The individual color values can be extracted using standard bit-shifting or bit-masking methods.

Colors go up in intensity and alpha goes up in opacity. Therefore FF FF is white while 00 00 is completely transparent and 00 0F is black. The colorspace is rather limited but for my purposes I wanted that.

The second byte is defines the “run” length of this color, or the horizontal length along this row of pixels to use this color. This is a form of basic compression. A length of 1 means this is only one pixel, a length of 100 means this is a line 100 pixels long. Runs longer than or going off the end of a row are considered valid and will wrap onto the next line.

License

This project is licensed under the MIT License which you can read online at that link or in the LICENSE file