Table of Contents
QccIMGImageDetermineType, QccIMGImageRead, QccIMGImageWrite - read/write
image to/from file
#include "libQccPack.h"
int QccIMGImageDetermineType(QccIMGImage
*image);
int QccIMGImageRead(QccIMGImage *image);
int QccIMGImageWrite(QccIMGImage
*image);
QccIMGImageDetermineType() attempts to determine
the type of the image, setting the image->image_type field appropriately.
First, QccIMGImageDetermineType() checks to see whether image->image_type
is already set to something other than QCCIMGTYPE_UNKNOWN. If it is, QccIMGImageDetermineType()
returns immediately, making no changes to image. Otherwise, if image->image_type
is equal to QCCIMGTYPE_UNKNOWN, QccIMGImageDetermineType() checks to see
whether the file indicated by image->filename exists. If it does, it reads
the magic number from the file, and sets image->image_type to QCCIMGTYPE_PPM,
QCCIMGTYPE_PGM, QCCIMGTYPE_PBM, or QCCIMGTYPE_ICP according to the magic
number, or to QCCIMGTYPE_UNKNOWN if the magic number is not recognized.
On the other hand, if the file does not exist, QccIMGImageDetermineType()
attempts to determine the image type from the filename itself. If filename
ends in ".ppm", image->image_type is set to QCCIMGTYPE_PPM. If filename ends
in ".pgm", image->image_type is set to QCCIMGTYPE_PGM. If filename ends in
".pbm", image->image_type is set to QCCIMGTYPE_PBM. If filename ends in ".icp",
image->image_type is set to QCCIMGTYPE_ICP. Otherwise, image->image_type is
set to QCCIMGTYPE_UNKNOWN.
QccIMGImageRead() reads a QccIMGImage structure
from the file specified by image->filename. QccIMGImageDetermineType() is
called to determine the image file's type, and then the appropriate steps
are taken to read the specific file format.
QccIMGImageWrite() writes a
QccIMGImage structure to a file; the filename of the image file to be
written must be stored as image->filename. QccIMGImageDetermineType() is
called to determine the image file's type, and then the appropriate steps
are taken to write the specific file format.
These routines
return 0 on success and 1 on error.
QccIMGImage(3)
, QccPackIMG(3)
,
QccPack(3)
Copyright (C) 1997-2021 James E. Fowler
Table of Contents