lrast2viff(3)

LIBRARY ROUTINE
lrast2viff - converts a SUN raster image to the VIFF image format

LIBRARY CALL
#include "vinclude.h"
int
lrast2viff (rast_image, viff_image, invert_flag)
struct rast *rast_image;
struct xvimage **viff_image;
int invert_flag;

INPUT
Input to lrast2viff :

rast_image
    A SUN raster image of type struct rast that has the correct byte order for the machine processing the image

invert_flag
    resulting image is either photopositive (1) or photonegaative (0)

OUTPUT

viff_image
    A pointer to struct xvimage, this image will contain the converted image from SUN rast to VIFF.

MODIFICATIONS

DESCRIPTION
lrast2viff : lrast2viff is a library that converts a SUN raster image into a VIFF image.

This library will convert SUN raster image of depth 1, 8 or 24 into a VIFF image. This routine does not support SUN raster images that have been encoded using run-length compression. If the SUN raster image contains colormaps, those maps will be preserved in the VIFF image. The resulting VIFF image will be a BIT image if the SUN rater image had a depth of 1, or BYTE if the SUN raaster image had a depth of 8 or 24. In the case that the depth of the SUN image is equal to 24, then the VIFF image will contain 3 data bands (red, green and blue).

If the SUN raster image is of type bit (depth = 1), then the invert flag may be used to invert the image. If the image is not of type bit (depth = 1) then the -p option is ignored.

The SUN raster image is defined as follows:

    A Sun raster image file is composed of three parts: a header containing 8 integers, a possibly empty set of colormap values, and 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.

    The header is defined as follows:
                            int  ras_magic;
                            int  ras_width;
                            int  ras_height;
                            int  ras_depth;
                            int  ras_length;
                            int  ras_type;
                            int  ras_maptype;
    The ras_magic field always contains the value 0x59a66a95 (hex).
    The ras_width and ras_height are the width and height of the image given pixels.
    The ras_depth is the number of bits used per pixel (1, 8, or 24).
    The ras_length is the number of bytes used to store the data of the image.
    The ras_type field is one of the following:
            RT_OLD          0   -- Raw pixrect image in 68000 byte order
            RT_STANDARD     1   -- Raw pixrect image in 68000 byte order
            RT_BYTE_ENCODED 2   -- Run-length compression of bytes
            RT_EXPERIMENTAL 0xffff  -- Reserved for testing

    For historical reasons, files of type RT_OLD will usually have a 0 in the ras_length field and therefore the actual image length will need to be computed.

    The ras_maptype will be one of the following:
            RMT_NONE        0   --ras_maplength is expected to be 0
            RMT_EQUAL_RGB   1   --red[ras_maplength/3],green[],blue[]
            RMT_RAW         2   --Sun's registered maptype

    If ras_maptype is not RMT_NONE and the ras_maplength is not 0, then the colormap values are the ras_maplength bytes immediately following the header. The ras-maplength is the number of bytes used to store the images colormap. These values are either uninterpreted bytes (usually with the ras_maptype set to RMT_RAW) or the equal length red, green and blue vectors, in that order (when the ras_maptype is RMT_EQUAL_RGB). In the latter case, the ras_maplength must be three times the size in bytes of any one of the vectors.

SEE ALSO
rast2viff(1), intro(3), vipl(3), verror(3), vutils(3)

RESTRICTIONS

lvrast2viff always assumes that the SUN raster image is in IEEE or Big Endian byte order (SUN's Byte Order).

AUTHOR
Tom Sauer

COPYRIGHT
Copyright 1991, University of New Mexico. All rights reserved.