An XRH file stores a rectangular raster image of one or more channels, each channel stored as scanlines in raster order (top-down, left-to-right). A channel may also be referred to as an image plane or component. Each sample in a channel is a
XRH files have a .xrh file name extension. The file name extension is not case sensitive. Each file begins with a File Header, followed with Comments, followed with Custom Properties, followed with optional Channel Names, and followed with the Image Planes (channels of pixel samples) to the end of the file.
The first 128 bytes of an XRH file are the file header:
The first 16 bytes of an XRH file (beginning of the file header) is the following ASCII text string including a terminating null:
These first 16 bytes of an XRH file (bytes 0−15) are the bytes 0x27, 0x58, 0x52, 0x48, 0x27, 0x66, 0x69, 0x6C, 0x65, 0x66, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x00 in that order.
The next four bytes of the file (bytes 16−19) store the file version number. The current version number is 0x00010000. Remember that this number, and all other multi-byte numbers in an XRH file, are stored in Big Endian format (network byte order).
The next four bytes (20−23) store the number of samples (pixels) per scanline (Image Width), followed with four bytes (bytes 24−27) that store the number of image scanlines (Image Height). Each channel has this many scanlines and this many samples per scanline.
The next four bytes (28−31) specify the number of channels (image planes).
The next 16 bytes (32−47) specify an optional viewport. If these bytes are all zero (the default), then the viewport is the entire image. Otherwise 4 unsigned integers specify the minimum x, minimum y, x width and y height of the viewport in that order; x and y are measured left-to-right and top-down respectively.
A viewport is the intended final image. Having extra pixels outside of the viewport may be useful for image processing of intermediate images.
The next 4 bytes (48−51) specify the type of color transformation. Zero indicates there is no color transformation. One (1) indicates the first three channels are Y, Cb and Cr in that order, transformed from RGB (in that order) using the ITU-R BT.709 standard.
Color Transformation can equal 1 only if there are at least three image channels and the first three channels use lossy compression. In that case (with Color Transformation equal to 1), the first three channels are considered RGB before storage, and are transformed to (stored as) YCbCr.
For more information, see the Color Transformations page.
The next 64 bytes (52−115) specify optional chromaticites for the ITU-R BT.709 color transformation, in case color transformation is performed. If these bytes are all zero (the default), then default chromaticites are used. Otherwise 8 FLOAT64 numbers specify custom red X, red Y, green X, green Y, blue X, blue Y, white X and white Y chromaticities in that order.
The next 12 bytes (116−127) are the last 12 bytes of the file header and must store the ASCII text string EndOfHeader\0 (including the terminating null character). This ASCII text string is stored without storing a count of how many characters it has (since it is fixed width and known to be 12 bytes including the terminating null character).
That marks the end of the header of a version 1.0 XRH file.