next up previous contents index
Next: C. Making GMT Encapsulated Up: B. GMT file formats Previous: B.2.3 Boundary Conditions for   Contents   Index


B.3 Sun raster files

The Sun raster file format consists of a header followed by a series of unsigned 1-byte integers that represents the bit-pattern. Bits are scanline oriented, and each row must contain an even number of bytes. The predefined 1-bit patterns in GMT have dimensions of 64 by 64, but other sizes will be accepted when using the -Gp$\vert$P option. The Sun header structure is outline in Table B.2.


Table B.2: Structure of a Sun rasterfile.

Parameter Description
int ras_magic Magic number
int ras_width Width (pixels) of image
int ras_height Height (pixels) of image
int ras_depth Depth (1, 8, 24, 32 bits) of pixel
int ras_length Length (bytes) of image
int ras_type Type of file; see RT_* below
int ras_maptype Type of colormap; see RMT_* below
int ras_maplength Length (bytes) of following map


After the header, the color map (if ras_maptype is not RMT_NONE) follows for ras_maplength bytes, followed by an image of ras_length bytes. Some related definitions are given in Table B.3.


Table B.3: Sun macro definitions relevant to rasterfiles.
Macro name Description
RAS_MAGIC 0x59a66a95
RT_STANDARD 1 (Raw pixrect image in 68000 byte order)
RT_BYTE_ENCODED 2 (Run-length compression of bytes)
RT_FORMAT_RGB 3 ([X]RGB instead of [X]BGR)
RMT_NONE 0 (ras_maplength is expected to be 0)
RMT_EQUAL_RGB 1 (red[ras_maplength/3],green[],blue[])


Numerous public-domain programs exist, such as xv and convert (in the ImageMagick package), that will translate between various rasterfile formats such as tiff, gif, jpeg, and Sun raster. Raster patterns may be created with GMT plotting tools by generating PostScript plots that can be rasterized by ghostscript and translated into the right raster format.


next up previous contents index
Next: C. Making GMT Encapsulated Up: B. GMT file formats Previous: B.2.3 Boundary Conditions for   Contents   Index
Paul Wessel 2004-10-01