-
Notifications
You must be signed in to change notification settings - Fork 44
IMG File Format (Sprite)
This page is about the .IMG sprite file format. For information about other IMG format types check out this page: IMG Format Types
#About IMG format The .IMG (sprite) file format is a compressed zlib archive holding a DDS texture. IMG files are known to hold only 1 single texture (not including mipmaps).
An example of an IMG file can be found in the ...\TwelveSky1\G03_GDATA\D01_GIMAGE2D\001
The IMG file has the following structure:
unsigned int uncompressedFileSize; // Size of data uncompressed
unsigned int compressedFileSize; // Size of compressed data
BYTE compressedFile[compressedFileSize];
That is: they have an 8 byte header, followed by zlib archive data.
-
uncompressedFileSize (offset 0 bytes) defines the size of the archive's contents whenever uncompressed.
-
compressedFileSize (offset 4 bytes) defines the size of the archive whenever it's contents has been compressed.
-
compressedFile[compressedFileSize] (offset 8 bytes) is zlib archive data, which is the side of compressedFileSize.
After the file is uncompressed, there should (Some files seem to only contain only the ddsH header, but no DDS data) be a .DDS file within. However, before the DDS file actually begins, there is an extra header attached to the beginning of the file. This extra header is dubbed: ddsH (Dubbed by @LiamKarlMitchell)
This ddsH header appears to assist the game engine in loading/drawing the sprite(DDS). If the game cannot load the ddsH Header, or if the header is corrupted, then the game will not not load the DDS texture.
The ddsH header has the following structure:
typedef enum D3DFORMAT {
D3DFMT_UNKNOWN = 0,
D3DFMT_R8G8B8 = 20,
D3DFMT_A8R8G8B8 = 21,
D3DFMT_X8R8G8B8 = 22,
D3DFMT_R5G6B5 = 23,
D3DFMT_X1R5G5B5 = 24,
D3DFMT_A1R5G5B5 = 25,
D3DFMT_A4R4G4B4 = 26,
D3DFMT_R3G3B2 = 27,
D3DFMT_A8 = 28,
D3DFMT_A8R3G3B2 = 29,
D3DFMT_X4R4G4B4 = 30,
D3DFMT_A2B10G10R10 = 31,
D3DFMT_A8B8G8R8 = 32,
D3DFMT_X8B8G8R8 = 33,
D3DFMT_G16R16 = 34,
D3DFMT_A2R10G10B10 = 35,
D3DFMT_A16B16G16R16 = 36,
D3DFMT_A8P8 = 40,
D3DFMT_P8 = 41,
D3DFMT_L8 = 50,
D3DFMT_A8L8 = 51,
D3DFMT_A4L4 = 52,
D3DFMT_V8U8 = 60,
D3DFMT_L6V5U5 = 61,
D3DFMT_X8L8V8U8 = 62,
D3DFMT_Q8W8V8U8 = 63,
D3DFMT_V16U16 = 64,
D3DFMT_A2W10V10U10 = 67,
// D3DFMT_UYVY = MAKEFOURCC('U', 'Y', 'V', 'Y'),
// D3DFMT_R8G8_B8G8 = MAKEFOURCC('R', 'G', 'B', 'G'),
// D3DFMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'),
// D3DFMT_G8R8_G8B8 = MAKEFOURCC('G', 'R', 'G', 'B'),
// D3DFMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'),
// D3DFMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'),
// D3DFMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'),
// D3DFMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'),
// D3DFMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'),
D3DFMT_D16_LOCKABLE = 70,
D3DFMT_D32 = 71,
D3DFMT_D15S1 = 73,
D3DFMT_D24S8 = 75,
D3DFMT_D24X8 = 77,
D3DFMT_D24X4S4 = 79,
D3DFMT_D16 = 80,
D3DFMT_D32F_LOCKABLE = 82,
D3DFMT_D24FS8 = 83,
D3DFMT_D32_LOCKABLE = 84,
D3DFMT_S8_LOCKABLE = 85,
D3DFMT_L16 = 81,
D3DFMT_VERTEXDATA =100,
D3DFMT_INDEX16 =101,
D3DFMT_INDEX32 =102,
D3DFMT_Q16W16V16U16 =110,
// D3DFMT_MULTI2_ARGB8 = MAKEFOURCC('M','E','T','1'),
D3DFMT_R16F = 111,
D3DFMT_G16R16F = 112,
D3DFMT_A16B16G16R16F = 113,
D3DFMT_R32F = 114,
D3DFMT_G32R32F = 115,
D3DFMT_A32B32G32R32F = 116,
D3DFMT_CxV8U8 = 117,
D3DFMT_A1 = 118,
D3DFMT_A2B10G10R10_XR_BIAS = 119,
D3DFMT_BINARYBUFFER = 199,
D3DFMT_FORCE_DWORD =0x7fffffff
};
typedef enum D3DRESOURCETYPE {
D3DRTYPE_SURFACE = 1,
D3DRTYPE_VOLUME = 2,
D3DRTYPE_TEXTURE = 3,
D3DRTYPE_VOLUMETEXTURE = 4,
D3DRTYPE_CubeTexture = 5,
D3DRTYPE_VERTEXBUFFER = 6,
D3DRTYPE_INDEXBUFFER = 7,
D3DRTYPE_FORCE_DWORD = 0x7fffffff
};
typedef enum D3DXIMAGE_FILEFORMAT {
D3DXIFF_BMP = 0,
D3DXIFF_JPG = 1,
D3DXIFF_TGA = 2,
D3DXIFF_PNG = 3,
D3DXIFF_DDS = 4,
D3DXIFF_PPM = 5,
D3DXIFF_DIB = 6,
D3DXIFF_HDR = 7,
D3DXIFF_PFM = 8,
D3DXIFF_FORCE_DWORD = 0x7fffffff
};
struct D3DXIMAGE_INFO {
UINT Width;
UINT Height;
UINT Depth;
UINT MipLevels;
D3DFORMAT Format;
D3DRESOURCETYPE ResourceType;
D3DXIMAGE_FILEFORMAT ImageFileFormat;
};
struct IMAGE_FILE {
D3DXIMAGE_INFO imageInfo;
char ddsType[4]; // (mismatched in some dds headers)
unsigned int ddsFileSize;
BYTE DDS[ddsFileSize]; // follows and is the size of ddsFileSize
}
(Credits to @LiamKarlMitchell, @epicws, @hobomchobo for finding this structure out.)
That is to say: the ddsH header is 36 Bytes in size. After the 36 bytes, then the actual .DDS portion of the file begins.
-
width (offset 0 bytes) defines how may X pixels to draw from the DDS file.
-
height (offset 4 bytes) defines how many Y pixels to draw from the DDS file.
-
unknown1 0x1
-
unknown2 0x1
-
compression (offset 16 bytes) defines how to treat the DDS's compression. 0x14 for DTX1, and 0x15 for DXT3.
It isn't exactly clear how this definition works - seeing that the DDS data defines it's own compression as well. Also, some ddsH headers have mismatched compressions that don't match the DDS file itself - although mismatched, the IMG still seems to work.
Although this phenomenon seems to work at times, it is recommended that when repackaging a IMG file compression, the DDS's compression, and ddsType all be defined to agree with each other.
(It should be noted that compression might be used by the engine, and not so much for the DDS itself. This conclusion is drawn because some times the ddsh's compressions don't match the DDS)
-
unknown3 0x3
-
unknown4 0x2
-
char ddsType[4] (offset 28 bytes) this is a 4 byte character array that defines the type of compression defined in the ddsH header.
-
ddsFileSize (offset 32 bytes) describes the size of the actual DDS.
-
DDS[ddsFileSize] The DDS file itself. The size of which is described by ddsFileSize.
(It should be noted that the unknown variables seem to be constant amongst ddsH headers. Therefore, their functions aren't exactly known. Also, the unknown variables might hold data pertaining to bits per pixel? or version info? direct x sprite drawing region data?)
This is just a standard dds file which can be viewed/edited easily.
You can get tools to view and edit DDS file here http://developer.nvidia.com/object/nv_texture_tools.html
I suggest you use the thumbnail viewer. Irfan view can also view dds files or there is the viewer in the Direct X SDK.
When using the photoshop plugin for DDS files by Nvidia: (Same applys for GIMP plugin)
When saving DDS textures in photosop, select DXT3 from the drop down, and select the "No MIP maps" radio button under 'MIP Map Generation'.
Make sure your alpha channel in Photoshop has been edited too :)
to get the black outline around the text, duplicate your white text layer and under Layer Effects give it a stroke of 1px, with the the color set to white.
Then simply copy this to the alpha channel
Inside G03_GDATA\D01_GIMAGE2D\
you will find the following kinds of sprites/textures for the game GUI.
Directory | What is in there |
---|---|
001 | GUI |
002 | Items |
003 | Skills/Actions |
004 | Skill Information Popups |
005 | Game Data (Technically not .IMG/Graphics just shares the same extension) |
006 | Help Screen |
007 | Buff Icons |
008 | Loading Screens |
010 | Effects |
Inside G03_GDATA\D07_GWORLD
There are Minimap files. 3 zoom levels for each.
Note: In TS2 the Game Data .IMG files were compressed in the same way in TS1 they are uncompressed. Note: In the old (beta?) version of TS1 (Chinese version) the game data files are compressed. The structures are also smaller in size and have different lengths for text/descriptions etc.
-
IMGTool https://www.dropbox.com/s/f477qkrp7ibnxck/IMGTools.rar?dl=0 But it won't work every time it does not generate a ddsH according to your dds.
-
Convert 2 DDS online. http://online-converting.com/image/convert2dds/ An online tool for converting png to dds etc.
-
Convert image to PNG: http://image.online-convert.com/convert-to-png An online tool for converting DDS to png.
-
IP Sniffer: http://www.majorgeeks.com/files/details/ip_sniffer.html Menu Path: Tools>System>Compress(Zlib) A utility that comes with at zlib compressor and uncompressor. (Use at your own risk. Scan before using!)
-
zlib home page: http://www.zlib.net/ Information about how to use zlib, and a place where the zlib library/sourcecode can be downloaded.
-
offzip: http://aluigi.altervista.org/mytoolz/offzip.zip a command line tool that can be handy for extracting compressed data from any file that uses zlib without knowing the structure of that file. (compressed zlib data starts with an x)
Tex files are just renamed DDS files.