ppm

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

NAME

ppm - functions to support portable pixelmap programs  

SYNOPSIS

 

#include <ppm.h>

cc ... libppm.a libpgm.a libpbm.a

 

DESCRIPTION

 

TYPES AND CONSTANTS

 

typedef gray pixval;

#define PGM_MAXMAXVAL 255 typedef struct
    {
    pixval r, g, b;
    } pixel; extern pixval ppm_pbmmaxval;

Each pixval should contain only the values between 0 and PGM_MAXMAXVAL. 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.  

PIXEL MANIPULATIONS

 

pixval PPM_GETR(p)

pixel p;

pixval PPM_GETG(p) pixel p;

pixval PPM_GETB(p) pixel p;

These three macros retrieve the red, green or blue value from the given pixel.  

void PPM_ASSIGN(p,red,grn,blu)

pixel p; pixval red, grn, blu;

This macro assigns the given red, green and blue values to the pixel.  

int PPM_EQUAL(p,q)

pixel p, q;

This macro checks two pixels for equality.  

void PPM_CSCALE(newp, p, oldmaxval, newmaxval)

pixel newp, p; pixval oldmaxval, newmaxval;

This macro scales the colors of pixel p according the old and new maximum values and assigns the new values to newp. It is intended to make writing ppmtowhatever easier.  

double PPM_LUMIN(p)

pixel p;

This macro determines the luminance of the pixel p.  

PGM MEMORY MANAGEMENT

 

pixel **pgm_allocarray(int cols, int rows)

Allocate an array of pixels.  

pixel *pgm_allocrow( int cols

Allocate a row of the given number of pixels.  

void pgm_freearray( pixelrow, rows

Free the array allocated with pgm_allocarray() containing the given number of rows.  

pbm_freerow( pixelrow

Free a row of pixels.  

READING PBM FILES

 

void

ppm_readppminit( file, colsP, rowsP, maxvalP, formatP ) FILE *file; int *colsP, *rowsP, *formatP; pixval *maxvalP;

Read the header from a pgm file, filling in the rows, cols, maxval and format variables.  

void

ppm_readppmrow( file, pixelrow, cols, maxval, format ) FILE *file; pixel *pixelrow; pixval maxval; int cols, format;

Read a row of pixels into the pixelrow array. Format and cols were filled in by ppm_readppminit().  

pixel **

ppm_readppm( file, colsP, rowsP, maxvalP ) FILE *file; int *colsP, *rowsP; pixval *maxvalP;

Read an entire pixelmap file into memory, returning the allocated array and filling in the rows, cols and maxval variables. This function combines ppm_readppminit(), ppm_allocarray() and ppm_readppmrow().  

WRITING PGM FILES

 

void

ppm_writeppminit( file, cols, rows, maxval ) FILE *file; int cols, rows; pixval maxval;

Write the header for a portable pixelmap file.  

void

ppm_writeppmrow( file, pixelrow, cols, maxval ) FILE *file; pixel *pixelrow; int cols; pixval maxval;

Write a row from a portable pixelmap.  

void

ppm_writeppm( file, bits, cols, rows, maxval ) FILE *file; pixel **bits; int cols, rows; pixval maxval;

Write the header and all data for a portable pixelmap. This function combines ppm_writeppminit() and ppm_writeppmrow().  

pixel ppm_backgroundpixel(pixels, cols, rows)

pixel **pixels; int cols; int rows;

Intuit the value of the background.  

SEE ALSO

pgm(3), ppm(3)  

AUTHOR

Manual by Tony Hansen.

Copyright (C) 1989 by 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.


 

Index

NAME
SYNOPSIS
#include <ppm.h>
DESCRIPTION
TYPES AND CONSTANTS
typedef gray pixval;
PIXEL MANIPULATIONS
pixval PPM_GETR(p)
void PPM_ASSIGN(p,red,grn,blu)
int PPM_EQUAL(p,q)
void PPM_CSCALE(newp, p, oldmaxval, newmaxval)
double PPM_LUMIN(p)
PGM MEMORY MANAGEMENT
pixel **pgm_allocarray(int cols, int rows)
pixel *pgm_allocrow( int cols )
void pgm_freearray( pixelrow, rows )
pbm_freerow( pixelrow )
READING PBM FILES
void
void
pixel **
WRITING PGM FILES
void
void
void
pixel ppm_backgroundpixel(pixels, cols, rows)
SEE ALSO
AUTHOR

This document was created by man2html, using the manual pages.
Time: 21:53:49 GMT, February 02, 2023