Channel names are optional. A Channel Names block is required, but may not have any channel names.
If channel names are used, a name must be provided for each channel, in the order the channels are stored: the first channel name must be the name of the channel that is stored first in the XRH file, the second channel name must be the name of the channel that is stored second, etc.
The Channel Names block (henceforth referred to as the Names block) begins with a 4-byte start-of-names marker, followed with a Size integer, followed with a Count integer, followed with the channel names (if any), and ending with a 4-byte end-of-name marker.
The first four bytes of the Names block stores the value 0x534F4E00 (ASCII string SON\0) which marks the start-of-names.
Start of Names Marker: SON\0
The Size integer immediately follows. It is a 32-bit integer that specifies the total size (number of bytes) of the entire Names block including the Size integer and the start-of-names marker.
The Count integer follows. It is a 32-bit integer that specifies how many channel names there are. That is followed with that many channel names.
The Count integer of a Names block must be either zero or equal to the Number of Channels integer of the XRH file header. If this Count integer is zero, there are no channel names stored and the Count integer is immediately followed with the 4-byte end-of-names marker. Otherwise, if the Count integer is nonzero, that many channel names follow, after which the 4-byte end-of-names marker is stored.
The last four bytes of the Names block is the end-of-names marker 0x454F4E00 (ASCII string EON\0) marking the end of the Names block.
End of Names Marker: EON\0
Channel names must be ASCII text, one channel name for each channel of pixel samples. Channel names are stored in the same order that the channels are stored.
Each Name is a 32-bit integer that specifies how many characters there are in the channel name (including a terminating null byte), followed with that many ASCII characters which are the channel name (including the terminating null byte).
The shortest possible Names block, for no channel names, would be 16 bytes. In that case, the first four bytes of the Names block would be the start-of-names marker, followed with a 4-byte integer equal to 16 (the total size of the Names block), followed with a 4-byte integer equal to zero indicating there was zero channel names in the Names block, and the last four bytes storing the end-of-names marker.
Newer XRH version recommended for new applications: