wvImageIO(3) USC Math Department
Back to wvlib import function index
wvImageIO(3)

Name

wvFReadImage, wvFWriteImage - image file import/export

Synopsis

#include <wv/io_image.h>

WVimage *wvFReadImage(FILE *fp);

wvBool wvFWriteImage(WVimage *image, FILE *fp, WVimageFileType imgType, const char *comments);

Description

wvFReadImage reads an image from the input stream fp. The file format is determined from the file header. If the header is not recognized, a NULL pointer is returned.

wvFWriteImage writes image to the output stream fp using the file format specified by imgType. The comments will be embedded in the image file header, if possible.

The WVimage data type is defined in <io_image.h> as:

typedef struct _WVimage {
    unsigned char   numChannels;
    WVmatrix      **channel;
} WVimage;

numChannels is the number of channels which make up the image. A grayscale or black-and-white image has one channel (the brightness), while a color image typically has three color channels: red, green, and blue.

channel is an array of pointers to matrices, one for each channel in the image.

Supported file formats are:

WV_IMAGEFILE_PPMraw PPM (RGB color pixelmap) format
WV_IMAGEFILE_PGMraw PGM (grayscale pixelmap) format
WV_IMAGEFILE_RGBSilicon Graphics RGB format

See Also

wvMatrix(3), ferr(3S), fopen(3S), fclose(3S)

Diagnostics

wvFReadImage returns a NULL pointer if the request cannot be completed (usually indicating that the process has run out of memory or that the file format is not recognized).

wvFWriteImage returns wvFalse if the request cannot be completed (usually indicating a problem with file I/O).


Back to wvlib import function index Last Updated: 02 February 1999