Difference between revisions of "Image file"

From Worms Knowledge Base

Jump to: navigation, search
(Flags)
(Note about alignment.)
(3 intermediate revisions by one other user not shown)
Line 9: Line 9:
 
* the number of bits per pixel in the image (usually 8) (1 byte)
 
* the number of bits per pixel in the image (usually 8) (1 byte)
 
* image flags (1 byte)
 
* image flags (1 byte)
* the number of colours in the image palette, excluding black<ref name=Black>The black colour isn't listed in the image palette, nor counted in the "number of colours" word. It is counted as the colour 0, so the palette stored in the file should be loaded starting from colour 1.</ref> (2 bytes)
+
* if the image has a palette (highest flag bit is set):
* the image palette, excluding black<ref name=Black/> ((3 &times; number of colours) bytes)
+
** the number of colours in the image palette, excluding black<ref name=Black>The black colour isn't listed in the image palette, nor counted in the "number of colours" word. It is counted as the colour 0, so the palette stored in the file should be loaded starting from colour 1.</ref> (2 bytes)
 +
** the image palette, excluding black<ref name=Black/> ((3 &times; number of colours) bytes)
 
* the image width (2 bytes)
 
* the image width (2 bytes)
 
* the image height (2 bytes)
 
* the image height (2 bytes)
* the image data. If the data is compressed (the corresponding image flag is set), see [[Team17 compression]] for the decompression routine; otherwise, it's just an array (Width &times; Height).
+
* the image data<ref name=DataAlignment>Embedded images in WWP land.dat files align their data by 4 bytes.</ref>. If the data is compressed (the corresponding image flag is set), see [[Team17 compression]] for the decompression routine; otherwise, it's just an array (Width &times; Height).
 
+
  
 
== Flags ==
 
== Flags ==
The flag byte is a bitmask of the following values:
+
The flag byte is a [[w:Bit field|bit field]] of the following values:
* 0x40 (01000000) - Image Data is Compressed.
+
* 0x40 (01000000) - set if the image data is compressed
* 0xC0 (11000000) - Image Data is Compressed (?).
+
* 0x80 (10000000) - the image has a palette
* 0x80 (10000000) - Image Data is Uncompressed.
+
  
 
== Notes ==
 
== Notes ==
 
<references />
 
<references />

Revision as of 09:10, 26 April 2017

(Up to File formats)

Team17's image files (typically with an .img file extension) are usually compressed palleted images.

File format

  • 4-byte signature - "IMG\x1A"
  • complete file length (4 bytes)
  • optionally, a null-terminated string describing the image (present only in some Worms 2 images)
  • the number of bits per pixel in the image (usually 8) (1 byte)
  • image flags (1 byte)
  • if the image has a palette (highest flag bit is set):
    • the number of colours in the image palette, excluding black[1] (2 bytes)
    • the image palette, excluding black[1] ((3 × number of colours) bytes)
  • the image width (2 bytes)
  • the image height (2 bytes)
  • the image data[2]. If the data is compressed (the corresponding image flag is set), see Team17 compression for the decompression routine; otherwise, it's just an array (Width × Height).

Flags

The flag byte is a bit field of the following values:

  • 0x40 (01000000) - set if the image data is compressed
  • 0x80 (10000000) - the image has a palette

Notes

  1. 1.0 1.1 The black colour isn't listed in the image palette, nor counted in the "number of colours" word. It is counted as the colour 0, so the palette stored in the file should be loaded starting from colour 1.
  2. Embedded images in WWP land.dat files align their data by 4 bytes.
Personal tools