Description
The gta3.img file is a file, which holds, models, textures, col, animations, and more.
It can be opened and edited with any made IMG editor, most notably, Alci's IMG Editor, and ImgTool 2.0
Structure
Version 2 archives, introduced with GTA San Andreas, combine .dir and .img files into one .img file. The directory has the same format as in version 1, but is located at the beginning of the archive. Files are again aligned to 2 KB boundaries. File offsets are relative to the start of the whole archive, not to the end of the file list.
- Code:
Header:
4 byte - CHAR[4] - FourCC, always "VER2"
4 byte - DWORD - number of entries (n)
Entry: (repeated n times)
4 byte - DWORD - offset of file inside archive (in blocks)
4 byte - DWORD - size of file (in blocks)
24 byte - CHAR[24] - name of file
A major drawback of this format is the complicated extendability. If you have to add many files, it might happen that you run out of space for the directory, and have to move the first file(s) to the end.
Relating to GTA 4
GTA IV introduced yet another .img file format. Not only the format is new, also there can be encrypted archives. The internal IMG parser of the game works with 2 KB buffers, which means that the 2 KB bounds from earlier versions (blocks) are still present.
IMG Header
The header of an unencrypted file always has a size of 20 bytes.
- Code:
4 byte - DWORD - Identifier (0xA94E2A52 if the archive is not encrypted)
4 byte - DWORD - Version (always 3, if not the format would be differ)
4 byte - DWORD - Number of Items
4 byte - DWORD - Table Size (in bytes)
2 byte - WORD - Size of Table Items (needs to be always 0x10)
2 byte - WORD - Unknown
IMG Table
The table holds information about the items. Each item header has a size of 16 bytes .
- Code:
4 byte - DWORD - Itemsize (in bytes)
4 byte - DWORD - Resource type
4 byte - DWORD - Offset (in blocks)
2 byte - WORD - Used Blocks
2 byte - WORD - Padding
Item Names' length will be calculate as :
Table Size - (Number of Items * Item Size)
Next that string will be split by '\x0'
A res source type is identified by the 4b DWORD value:
- Code:
* 0x01: Generic
* 0x08: Texture archive
* 0x20: Bounds
* 0x6E: Model file
* 0x24: xpfl
Links
San Andreas
ImgTool 2.0
Alci's IMG Editor
GTA IV
G-Tools
Spark IV
Open GTA IV