Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

pgm(3)

ppm(3)

pgm(3)  —  C LIBRARY FUNCTIONS

NAME

pgm - functions to support portable graymap programs

SYNOPSIS

#include <pgm.h>
cc ... libpgm.a libpbm.a

DESCRIPTION

TYPES AND CONSTANTS

typedef unsigned char gray;
#define PGM_MAXMAXVAL 255
extern gray pgm_pbmmaxval;

Each gray should contain only the values between 0 and PGM_MAXMAXVAL. pgm_pbmmaxval is the maxval used when a PGM program reads a PBM file.  Normally it is 1; however, for some programs, a larger value gives better results. 

PGM MEMORY MANAGEMENT

gray ∗∗pgm_allocarray(int cols, int rows)

Allocate an array of grays.

gray ∗pgm_allocrow( int cols )

Allocate a row of the given number of grays.

void pgm_freearray( grayrow, rows )

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

pbm_freerow( grayrow )

Free a row of grays.

READING PBM FILES

void
pgm_readpgminit( file, colsP, rowsP, maxvalP, formatP )
FILE ∗file;
int ∗colsP, ∗rowsP, ∗formatP;
gray ∗maxvalP;

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

void
pgm_readpgmrow( file, grayrow, cols, maxval, format )
FILE ∗file;
gray ∗grayrow;
gray maxval;
int cols, format;

Read a row of grays into the grayrow array. Format and cols were filled in by pgm_readpgminit().

gray ∗∗
pgm_readpgm( file, colsP, rowsP, maxvalP )
FILE ∗file;
int ∗colsP, ∗rowsP;
gray ∗maxvalP;

Read an entire graymap file into memory, returning the allocated array and filling in the rows, cols and maxval variables. This function combines pgm_readpgminit(), pgm_allocarray() and pgm_readpgmrow().

WRITING PGM FILES

void
pgm_writepgminit( file, cols, rows, maxval )
FILE ∗file;
int cols, rows;
gray maxval;

Write the header for a portable graymap file.

void
pgm_writepgmrow( file, grayrow, cols, maxval )
FILE ∗file;
gray ∗grayrow;
int cols;
gray maxval;

Write a row from a portable graymap.

void
pgm_writepgm( file, bits, cols, rows, maxval )
FILE ∗file;
gray ∗∗bits;
int cols, rows;
gray maxval;

Write the header and all data for a portable graymap. This function combines pgm_writepgminit() and pgm_writepgmrow().

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.

Amiga Unix  —  Last change:

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026