GM1 file format

==File outline==
*File Header 
*Palette
*Image offset list
*Image sizes list
*Image Headers
*Images
==File Header==
The header has a length of 88-bytes, composed of unsigned 32-bit integers:
* 4 bytes – Unknown
* 4 bytes – Unknown
* 4 bytes – Unknown
* 4 bytes – Quantity, number of pictures in file.
* 4 bytes – Unknown
* 4 bytes – Data Type
* 56 bytes – Unknown, array of 32bit integers.
* 4 bytes – Data Size
* 4 bytes – Unknown
===Data Type===
Data type is and ID that represents what kind of images are stored, they are as follows:
:1 – Interface items and some building animations. Images are stored similar to TGX images.
:2 – Animations.
:3 – Buildings. Images are stored similar to TGX images but with a Tile object.
:4 – Font. TGX format.
:5 and 7 – Walls, grass, stones and other. No compression, stored with 2-bytes per pixel.
:
====Tile Object====
A 30x16 tile that is placed under the building part. The tile object is 512 bytes in size, or 256 pixels (2-bytes per pixel). It is stored like a diamond. Starting with 2 pixels in the first line and then increasing to 6, then 10 and continues in increments of 4 till it reaches 30 and then works its way down also in increments of 4.
Here is the list of pixels per line:
:2
:6
:10
:14
:18
:22
:26
:30
:30
:26
:22
:18
:14
:10
:6
:2
:
==Palette==
Size is always 5,120 bytes.
==Image Header==
Image Header has a length of 16 bytes
* 2 bytes – Image width
* 2 bytes – Image height
* 2 bytes – Width offset (Horizontal location of current frame on large surface)
* 2 bytes – Height offset (Vertical location of current frame on large surface)
* 1 byte – Image part (0 denotes the start of a new collection)
* 1 byte – Sub-parts (Number of following parts in the collection)
* 2 bytes – Tile offset (Vertical offset of the tile object on large surface)
* 1 byte – Direction, left,right, center... used for buildings only.
* 1 byte – Initial horizontal offset of image.
* 1 byte – Width of building part.
* 1 byte – Color, used for animated units only.
Images are composed of multiple parts, which are placed depending on the offsets described in the image header. If the file contains tile objects, they are placed under their respective image part to form a building.
Category:Stronghold games discussion