HG‐3 Image - trigger-segfault/TriggersTools.CatSystem2 GitHub Wiki
Some values unknown but still much more readable than other implementations
The first 12 bytes of this header uses the same structure as HG-2 Image's header.
Data Type | Value | Description |
---|---|---|
char[4] |
"HG-3" | File Signature |
uint32 |
HeaderSize | Size of this header, always 12 |
uint32 |
Version | HG-3 version number: 0x300
|
Frame[>] | Frames | A find-by-offset set of frames for this image |
The Version field is likely formatted as hex digits, but represented as a decimal version number. Because HG-2 Image's make use of 0x10
, 0x20
, and 0x25
, its possible that 0x300
is used to avoid any sort of conflicts.
Hex | Dec | Includes |
---|---|---|
0x300 |
v3.00 | Only version, not actually checked by Cs2 |
StartPosition = stream.Position
Position = StartPosition + FrameHeader.OffsetNext
StartPosition = stream.Position
do while FrameHeader.OffsetNext != 0
HG-3 images may have multiple frames of image data, each with their own dimensions and such. Each frame is looked by an ID. These IDs are always printed as a zero-padded 4-digit decimal number (however values larger than 9999 will print with more digits).
Oftentimes, multiple frames are all stored in one image for Menu assets where each frame is a different button or background, etc.
The frame header tells us the ID of the frame, which CatSystem2 looks for, and the offset to the next the next frame in the HG-3 image, if there is a next frame.
Data Type | Value | Description |
---|---|---|
uint32 |
OffsetNext | Offset to the next frame |
uint32 |
ID | Identifier for the frame used in game |
Tag[>] | Tags | A find-by-offset set of tags for this frame |
TagStartPosition = stream.Position
Position = TagStartPosition + Tag.OffsetNext
TagStartPosition = stream.Position
do while Tag.OffsetNext != 0
Following the Frame Header, is a set of tags specific to the frame. Similar to Frame Header, each tag also has an OffsetNext that points to the next tag until there are no more in the frame. See Tags section for the documented structure of all known tags.
Data Type | Value | Description |
---|---|---|
char[8] |
TagName | Name of the data structure following this tag |
uint32 |
OffsetNext | Offset to the next tag, 0 if no more tags in this frame |
uint32 |
Length | Length of this tag's data structure |
byte[Tag.Length] | TagData | Tag-specific data |
These are all the known tag types that can appear in a frame, some tags have a required order before or after other tags. These tags are only considered part of the current frame. Each tag type has a different way of reading the data. See below for a list of known tags and their structure.
stdinfo
contains basic information about the frame, such as dimensions, bit depth, offset, etc. This tag must always be the first tag in a frame (confirmed in assembly).
The tag name (stdinfo
) possibly stands for "Standard Info".
Data Type | Value | Description |
---|---|---|
uint32 |
Width | Condensed width of the image (without transparency) |
uint32 |
Height | Condensed height of the image (without transparency) |
uint32 |
BitDepth | Number of bits per pixel, 24 or 32 |
int32 |
OffsetX | Horizontal offset of the image from the left |
int32 |
OffsetY | Vertical offset of the image from the top |
uint32 |
TotalWidth | Total width of the image with OffsetX applied |
uint32 |
TotalHeight | Total height of the image with OffsetY applied |
bool32 |
IsTransparent | True if transparency is used in the image |
int32 |
BaseX | Horizontal center of the image, used for drawing in-game |
int32 |
BaseY | Vertical center of the image, used for drawing in-game |
The IsTransparent field is referred to as a Transparency Specifier in 1990's/2000's standard image formats (like TIFF)
Where ####
is replaced with a four digit number, padded with zeros. A number other than 0000
has never been observed.
Each numbered tag contains one slice of data for the same image. Each slice defines a range of rows (scan lines) within said image.
The tag name (img
####) stands for "Image [IDNo.]".
Specifies a standard image type that both HG-2 and HG-3 images use. The encoding is nearly if not exactly identical to what is described in this patent, filed in 1988.
Data Type | Value | Description |
---|---|---|
uint32 |
SliceStart | The starting row of the image slice. (Only observed as zero) |
uint32 |
SliceLength | The number of rows in the image slice. (Only observed as Stdinfo.Height) |
uint32 |
CompressedDataLength | Compressed length of Zero Run-length copy data |
uint32 |
DecompressedDataLength | Decompressed length of Zero Run-length copy data |
uint32 |
CompressedCmdLength | Compressed length of Zero Run-length copy command bits |
uint32 |
DecompressedCmdLength | Decompressed length of Zero Run-length copy command bits |
byte[CompressedDataLength] | RleData | Compressed Zero Run-length copy data |
byte[CompressedCmdLength] | RleCmd | Compressed Zero Run-length copy command bits |
See HG‐X ProcessImage for how standard HG-2 and HG-3 image data is made readable.
Specifies JPEG compressed image file data, that can optionally be combined with Tag "img_al".
The tag name (img_jpg
) stands for "Image JPEG".
Unlike other tag structures, this structure requires the Tag.Length field.
Data Type | Value | Description |
---|---|---|
byte[Tag.Length] | JpegData | Raw JPEG file data |
When combined with Tag img_al
, all alpha bytes for the JPEG image overwritten by Tag img_al
's alpha bytes.
Specifies image alpha data that is to be added to Tag "img_jpg".
This tag is only looked for after reading an img_jpg
tag.
The tag name (img_al
) stands for "Image Alpha".
Unlike the output of Tag img####
+ HG‐X ProcessImage, there is no padding for the stride of the alpha bytes.
Data Type | Value | Description |
---|---|---|
uint32 |
CompressedLength | Compressed length of AlphaData bytes |
uint32 |
DecompressedLength | Decompressed length of AlphaData bytes |
byte[CompressedLength] | AlphaData | Zlib compressed alpha bytes, one byte per pixel |
Undocumented image format. It's possible this is a new form to declare a JPEG image with alpha mask.
Specifies WEBP image file data.
The tag name (img_wbp
) stands for "Image WebP".
Unlike other tag structures, this structure requires the Tag.Length field.
Data Type | Value | Description |
---|---|---|
byte[Tag.Length] | WebPData | Raw WEBP file data |
Where ####
is replaced with a four digit number, padded with zeros.
The ####
represents the ID of the attribute which is used to reference it in-game.
Specifies an Attribute, which is a set of coordinates, size, and color for drawing sprites on top of other sprites, such as the 💢 (anger) manpu.
Data Type | Value | Description |
---|---|---|
int32 |
X | X coordinate of the attribute relative to the left of the current frame |
int32 |
Y | Y coordinate of the attribute relative to the top of the current frame |
uint32 |
Width | Width to draw the image with |
uint32 |
Height | Height to draw the image with |
uint32 |
Color | Color to draw the image with, Format: #AARRGGBB (TODO: reconfirm) |
It is unknown what this tag specifies, but it is always present at the end of every frame's list of tags.
The tag name (cptype
) likely stands for "CG Page Type", which would explain its appearance in CG menu thumbnails, only.
Data Type | Value | Description |
---|---|---|
uint32 |
Type | Unknown, very rarely non-zero Other known value is 3 , found in CG menu images |
It is unknown what this tag specifies. This tag is very uncommon, and may only be present in newer commercial versions of the CatSystem2 engine.
The tag name (imgmode
) likely stands for Image Mode.
Data Type | Value | Description |
---|---|---|
bool32 |
Mode | Common in newer games, present on CG. Value is always 0 when present, defaults to 1
|