home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
NETWORK
/
netpbm_src.lzh
/
NETPBM
/
PPM
/
libppm.3
< prev
next >
Wrap
Text File
|
1996-11-18
|
5KB
|
165 lines
.TH libppm 3
.SH NAME
libppm - functions to support portable pixmap programs
.SH SYNOPSIS
.de Ss
.sp
.ft CW
.nf
..
.de Se
.fi
.ft P
.sp
..
.Ss
#include <ppm.h>
cc ... libppm.a libpgm.a libpbm.a
.Se
.SH DESCRIPTION
.SS TYPES AND CONSTANTS
.Ss
typedef ... pixel;
typedef ... pixval;
#define PPM_MAXMAXVAL ...
extern pixval ppm_pbmmaxval;
.Se
Each
.BR pixel
contains three
.BR pixval s,
each of which should contain only the values between
.BR 0
and
.BR PPM_MAXMAXVAL .
.BR ppm_pbmmaxval
is the maxval used when a PPM program reads a PBM file.
Normally it is 1; however, for some programs, a larger value gives better
results.
.Ss
#define PPM_FORMAT ...
#define RPPM_FORMAT ...
#define PPM_TYPE PPM_FORMAT
int PPM_FORMAT_TYPE( int format )
.Se
For distinguishing different file formats and types.
.Ss
pixval PPM_GETR( pixel p )
pixval PPM_GETG( pixel p )
pixval PPM_GETB( pixel p )
.Se
These three macros retrieve the red, green or blue value from the given
pixel.
.Ss
void PPM_ASSIGN( pixel p, pixval red, pixval grn, pixval blu )
.Se
This macro assigns the given red, green and blue values to the pixel.
.Ss
int PPM_EQUAL( pixel p, pixel q )
.Se
This macro checks two pixels for equality.
.Ss
void PPM_DEPTH( pixel newp, pixel p, pixval oldmaxval, pixval newmaxval )
.Se
This macro scales the colors of pixel
.BR p
according the old and new maximum values and assigns the new values to
.BR newp .
It is intended to make writing ppmtowhatever easier.
.Ss
float PPM_LUMIN( pixel p )
.Se
This macro determines the luminance of the pixel
.BR p .
.SS MEMORY MANAGEMENT
.Ss
pixel** ppm_allocarray( int cols, int rows )
.Se
Allocate an array of pixels.
.Ss
pixel* ppm_allocrow( int cols )
.Se
Allocate a row of the given number of pixels.
.Ss
void ppm_freearray( pixel** pixels, int rows )
.Se
Free the array allocated with
.BR ppm_allocarray()
containing the given number
of rows.
.Ss
void pbm_freerow( pixel* pixelrow )
.Se
Free a row of pixels.
.SS READING PBM FILES
.Ss
void ppm_readppminit( FILE* fp, int* colsP, int* rowsP, pixval* maxvalP, int* formatP )
.Se
Read the header from a PPM file, filling in the rows, cols, maxval and format
variables.
.Ss
void ppm_readppmrow( FILE* fp, pixel* pixelrow, int cols, pixval maxval, int format )
.Se
Read a row of pixels into the pixelrow array.
Format, cols, and maxval were filled in by
.BR ppm_readppminit() .
.Ss
pixel** ppm_readppm( FILE* fp, int* colsP, int* rowsP, pixval* maxvalP )
.Se
Read an entire pixmap file into memory, returning the allocated array and
filling in the rows, cols and maxval variables.
This function combines
.BR ppm_readppminit() ,
.BR ppm_allocarray()
and
.BR ppm_readppmrow() .
.SS WRITING FILES
.Ss
void ppm_writeppminit( FILE* fp, int cols, int rows, pixval maxval, int forceplain )
.Se
Write the header for a portable pixmap file.
The forceplain flag forces a plain-format file to be written, as opposed
to a raw-format one.
.Ss
void ppm_writeppmrow( FILE* fp, pixel* pixelrow, int cols, pixval maxval, int forceplain )
.Se
Write a row from a portable pixmap.
.Ss
void ppm_writeppm( FILE* fp, pixel** pixels, int cols, int rows, pixval maxval, int forceplain )
.Se
Write the header and all data for a portable pixmap.
This function combines
.BR ppm_writeppminit()
and
.BR ppm_writeppmrow() .
.SS COLOR NAMES
.Ss
pixel ppm_parsecolor( char* colorname, pixval maxval )
.Se
Parses an ASCII color name into a pixel.
The color can be specified in three ways. One, as a name, assuming
that a pointer to an X11-style color names file was compiled in. Two,
as an X11-style hexadecimal number: #rgb, #rrggbb, #rrrgggbbb, or
#rrrrggggbbbb. Three, as a triplet of decimal floating point numbers
separated by commas: r.r,g.g,b.b.
.Ss
char* ppm_colorname( pixel* colorP, pixval maxval, int hexok )
.Se
Returns a pointer to a string describing the given color.
If the X11 color names file is available and the color appears in
it, that name is returned.
Otherwise, if the hexok flag is true then a hexadecimal colorspec
is returned; if hexok is false and the X11 color names file is
available, then the closest matching color is returned;
otherwise, it's an error.
.SH "SEE ALSO"
pbm(3), pgm(3)
.SH AUTHOR
Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer.
.\" Permission to use, copy, modify, and distribute this software and its
.\" documentation for any purpose and without fee is hereby granted, provided
.\" that the above copyright notice appear in all copies and that both that
.\" copyright notice and this permission notice appear in supporting
.\" documentation. This software is provided "as is" without express or
.\" implied warranty.