Difference between revisions of "Image file"

From Worms Knowledge Base

Jump to: navigation, search
(Note about alignment.)
(Create table from file format specification.)
Line 4: Line 4:
 
== File format ==
 
== File format ==
  
* 4-byte signature - "IMG\x1A"
+
{| class="wikitable"
* complete file length (4 bytes)
+
! Game !! Type !! Size !! Name !! Description
* 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)
+
| {{software|W2|WA|WWP}} || uint8[4] || 4 || Signature || Always "IMG\x1A".
* image flags (1 byte)
+
|-
* if the image has a palette (highest flag bit is set):
+
| {{software|W2|WA|WWP}} || uint32 || 4 || File Size || Complete length of the file, in 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)
+
| {{software|W2}} || string0 || - || Description || An optional, null-terminated string, only present in some Worms 2 images.
* the image width (2 bytes)
+
|-
* the image height (2 bytes)
+
| {{software|W2|WA|WWP}} || uint8 || 1 || Bits Per Pixel || Usually 8 (256 colors).
* 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).
+
|-
 
+
| {{software|W2|WA|WWP}} || uint8 || 1 || Image Flags || A [[w:Bit field|bit field]] of the following values:
== Flags ==
+
* 1 << 6 (0x40) = Image data is [[Team17 compression|compressed]]; otherwise, it is an array of Width &times; Height pixels.
The flag byte is a [[w:Bit field|bit field]] of the following values:
+
* 1 << 7 (0x80) = Image has a palette, defined as follows:
* 0x40 (01000000) - set if the image data is compressed
+
|- style="background:#EEE"
* 0x80 (10000000) - the image has a palette
+
| {{software|W2|WA|WWP}} || uint16 || 2 || Palette Color Count || Only if palletized, excludes 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>.
 
+
|- style="background:#EEE"
== Notes ==
+
| {{software|W2|WA|WWP}} || rgb[colorCount] || 3 &times; color count || Palette Colors || Only if palletized, excludes black<ref name=Black/>. 3 bytes each color (RGB).
 +
|-
 +
| {{software|W2|WA|WWP}} || uint16 || 2 || Image Width || In pixels.
 +
|-
 +
| {{software|W2|WA|WWP}} || uint16 || 2 || Image Height || In pixels.
 +
|-
 +
| {{software|W2|WA|WWP}} || uint8[] || - || Image Data || Raw image data, according to the above<ref name=DataAlignment>Embedded images in WWP land.dat files align their data by 4 bytes.</ref>.
 +
|}
 
<references />
 
<references />

Revision as of 00:20, 30 June 2020

(Up to File formats)

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

File format

Game Type Size Name Description
[W2][WA][WWP] uint8[4] 4 Signature Always "IMG\x1A".
[W2][WA][WWP] uint32 4 File Size Complete length of the file, in bytes.
[W2][—][—] string0 - Description An optional, null-terminated string, only present in some Worms 2 images.
[W2][WA][WWP] uint8 1 Bits Per Pixel Usually 8 (256 colors).
[W2][WA][WWP] uint8 1 Image Flags A bit field of the following values:
  • 1 << 6 (0x40) = Image data is compressed; otherwise, it is an array of Width × Height pixels.
  • 1 << 7 (0x80) = Image has a palette, defined as follows:
[W2][WA][WWP] uint16 2 Palette Color Count Only if palletized, excludes black[1].
[W2][WA][WWP] rgb[colorCount] 3 × color count Palette Colors Only if palletized, excludes black[1]. 3 bytes each color (RGB).
[W2][WA][WWP] uint16 2 Image Width In pixels.
[W2][WA][WWP] uint16 2 Image Height In pixels.
[W2][WA][WWP] uint8[] - Image Data Raw image data, according to the above[2].
  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