RAST

Section: C Library Functions (3)
Index Return to Main Contents
 

NAME

rast - SUN rasterfile interface  

SYNOPSIS

#include ``rast.h''

RASTER *Ropen(filename,mode)
char *filename;
int mode;

RASTER Rdopen(filedes,mode)
int filedes, mode;

Rgetheader(raster)
RASTER *raster;

Rputheader(raster)
RASTER *raster;

Rgetpix(raster)
RASTER *raster;

Rputpix(raster,pixel)
RASTER *raster;
int pixel;

Rgetmappedpix(raster,value)
RASTER *raster;
int *value;

Rgetmappedpix(raster,red,green,blue)
RASTER *raster;
int *red, *green, *blue;

Rinitmap(raster,type,length)
RASTER *raster;
int type, length;

Rputmap(raster,index,value)
RASTER *raster;
int index, value;

Rputmap(raster,index,red,green,blue)
RASTER *raster;
int index, red, green, blue;

Rgetmap(raster,index,value)
RASTER *raster;
int index, *value;

Rgetmap(raster,index,red,green,blue)
RASTER *raster;
int index, *red, *green, *blue;

Rclose(raster)
RASTER *raster;

 

DESCRIPTION

This library provides pixel I/O for SUN rasterfiles.

Ropen opens a SUN rasterfile for reading or writing, and returns a RASTER structure. The mode should be R for read, W for write. R and W are defined in the file rast.h. Rdopen opens a stream, specified by a UNIX file descriptor. The RASTER structure is defined below.

After a rasterfile has been opened to read, data from the rasterfile header is fetched and placed in the RASTER structure with a call to Rgetheader. A rasterfile opened for output must have (at least) it's width, height, and depth set before the header may be written with Rputheader. If the header is to include a map, the map must be initialized with a call to Rinitmap. Map values may be set directly in the RASTER structure, or they my be set using Rputmap. The map type must be one defined in the include file <rasterfile.h>.

For convenience, map values may be retrieved with Rgetmap.

Each call to Rgetpix will return a raw pixel value from the rasterfile. Rgetmappedpix returns the result of putting the raw pixel value through the rasterfile map. Rputpix writes pixel values to the rasterfile.

A rasterfile is closed with Rclose.  

RASTER STRUCTURE

The data structure maintained by these routines is defined in the file rast.h.

typedef struct RASTER_STRUCT {
    int height;             /* number of rows                           */
    int width;              /* number of columns                        */
    int depth;              /* bits per pixel                           */
    int length;             /* bytes of data following header           */
    int type;               /* rasterfile type                          */
    int maptype;            /* type of lookup table                     */
    int maplength;          /* length of lookup table                   */
    char *map;              /* lookup table                             */
    int linelen;            /* bytes in a row (padded to even 16 bits)  */
    FILE *fp;               /* file pointer                             */
    int mode;               /* read (R) or write (W) mode flag          */
    char *cache;            /* cache of 1 row                           */
    int c_pixel;            /* current pixel in row cache               */
    struct pixrect *c_pr;   /* make cache look like a pixrect           */
} RASTER;

The height, width, depth, length, type, maptype, and maplength fields have exactly the same meaning as they do in rasterfiles. The map field is used to store the rasterfile map data.

The linelen field gives the number of bytes in a single line (row) in the rasterfile. This is different from the width because each line is padded with zero bits to make it an integer multiple of 16 bits in length.

The UNIX file pointer is kept in the fp field, and a read/write flag is kept in the mode field.

Pixels are stored in the cache field, which holds one line (row) of the raster. The cache is maintained by Rgetpix and Rputpix. The current pixel (column) within the cache is recorded by in the c_pixel field. The cache is efficiently accessed by turning it into a memory pixrect and using pr_get and pr_put to do the necessary bit stuffing. The memory pixrect is kept in the c_pr field. Because of this, programs using this library must be compiled with -lpixrect.  

AUTHOR

Marc Majka


 

Index

NAME
SYNOPSIS
DESCRIPTION
RASTER STRUCTURE
AUTHOR

This document was created by man2html, using the manual pages.
Time: 06:23:50 GMT, December 12, 2024