Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
A rasterfile is composed of three parts: first, a header containing 8 integers; second, a (possibly empty) set of colormap values; and third, the pixel image, stored a line at a time, in increasing y order. The image is layed out in the file as in a memory pixrect. Each line of the image is rounded up to the nearest 16 bits. "rasterfile"
The header is defined by the following structure:
struct rasterfile { int ras_magic; int ras_width; int ras_height; int ras_depth; int ras_length; int ras_type; int ras_maptype; int ras_maplength; };
The ras_magic field always contains the following constant:
#define \s-1RAS_MAGIC\s0 0x59a66a95The ras_width , ras_height , and ras_depth fields contain the image's width and height in pixels, and its depth in bits per pixel, respectively. The depth is either 1 or 8, corresponding to standard frame buffer depths. The ras_length field contains the length in bytes of the image data. For an unencoded image, this number is computable from the ras_width , ras_height , and ras_depth fields, but for an encoded image it must be explicitly stored in order to be available without decoding the image itself. Note: the length of the header and of the (possibly empty) colormap values are not included in the value of the ras_length field; it is only the image data length. For historical reasons, files of type RT_OLD will usually have a 0 in the ras_length field, and software expecting to encounter such files should be prepared to compute the actual image data length if needed. The ras_maptype and ras_maplength fields contain the type and length in bytes of the colormap values, respectively. If ras_maptype is not RMT_NONE and the ras_maplength is not 0, then the colormap values are the ras_maplength bytes immediately after the header. These values are either uninterpreted bytes (usually with the ras_maptype set to RMT_RAW\s0) or the equal length red, green and blue vectors, in that order (when the ras_maptype is RMT_EQUAL_RGB\s0). In the latter case, the ras_maplength must be three times the size in bytes of any one of the vectors.