Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ libpbm(3) — BSD/386 1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

libpgm(3)

libppm(3)

libpnm(3)



libpbm(3)                                               libpbm(3)


NAME
       libpbm - functions to support portable bitmap programs

SYNOPSIS
       #include <pbm.h>
       cc ... libpbm.a


DESCRIPTION - PACKAGE-WIDE ROUTINES
   KEYWORD MATCHING
       int pmkeymatch( char* str, char* keyword, int minchars )

       Does a case-insensitive match of str against keyword.  str
       can be a leading sunstring of keyword, but at  least  min-
       chars must be present.

   LOG BASE TWO
       int pmmaxvaltobits( int maxval )
       int pmbitstomaxval( int bits )

       Convert  between  a  maxval and the minimum number of bits
       required to hold it.

   MESSAGES AND ERRORS
       void pmmessage( char* fmt, ... )

       printf() style routine to write an informational  message.

       void pmerror( char* fmt, ... )

       printf()  style  routine  to  write  an  error message and
       abort.

       void pmusage( char* usage )

       Write a usage message.  The string  should  indicate  what
       arguments are to be provided to the program.

   GENERIC FILE MANAGEMENT
       FILE* pmopenr( char* name )

       Open  the  given  file for reading, with appropriate error
       checking.  A filename of "-" is  taken  as  equivalent  to
       stdin.

       FILE* pmopenw( char* name )

       Open  the  given  file for writing, with appropriate error
       checking.

       void pmclose( FILE* fp )

       Close the file descriptor, with appropriate  error  check-
       ing.



                                                                1




libpbm(3)                                               libpbm(3)


   ENDIAN I/O
       int pmreadbigshort( FILE* in, short* sP )
       int pmwritebigshort( FILE* out, short s )
       int pmreadbiglong( FILE* in, long* lP )
       int pmwritebiglong( FILE* out, long l )
       int pmreadlittleshort( FILE* in, short* sP )
       int pmwritelittleshort( FILE* out, short s )
       int pmreadlittlelong( FILE* in, long* lP )
       int pmwritelittlelong( FILE* out, long l )

       Routines  to  read and write short and long ints in either
       big- or little-endian byte order.

DESCRIPTION - PBM-SPECIFIC ROUTINES
   TYPES AND CONSTANTS
       typedef ... bit;
       #define PBMWHITE ...
       #define PBMBLACK ...

       each bit should contain only the values  of  PBMWHITE  or
       PBMBLACK.

       #define PBMFORMAT ...
       #define RPBMFORMAT ...
       #define PBMTYPE PBMFORMAT
       #define PBMFORMATTYPE(f) ...

       For distinguishing different file formats and types.

   INITIALIZATION
       void pbminit( int* argcP, char* argv[] )

       All PBM programs must call this routine.

   MEMORY MANAGEMENT
       bit** pbmallocarray( int cols, int rows )

       Allocate an array of bits.

       bit* pbmallocrow( int cols )

       Allocate a row of the given number of bits.

       void pbmfreearray( bit** bits, int rows )

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

       void pbmfreerow( bit* bitrow )

       Free a row of bits.

   READING FILES
       void pbmreadpbminit( FILE* fp, int* colsP, int* rowsP, int* formatP )



                                                                2




libpbm(3)                                               libpbm(3)


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

       void pbmreadpbmrow( FILE* fp, bit* bitrow, int cols, int format )

       Read a row of bits into the bitrow array.  Format and cols
       were filled in by pbmreadpbminit().

       bit** pbmreadpbm( FILE* fp, int* colsP, int* rowsP )

       Read an entire bitmap  file  into  memory,  returning  the
       allocated  array  and  filling  in the rows and cols vari-
       ables.    This   function   combines    pbmreadpbminit(),
       pbmallocarray() and pbmreadpbmrow().

   WRITING FILES
       void pbmwritepbminit( FILE* fp, int cols, int rows, int forceplain )

       Write  the  header for a portable bitmap file.  The force-
       plain flag forces a plain-format file to  be  written,  as
       opposed to a raw-format one.

       void pbmwritepbmrow( FILE* fp, bit* bitrow, int cols, int forceplain )

       Write a row from a portable bitmap.

       void pbmwritepbm( FILE* fp, bit** bits, int cols, int rows, int forceplain )

       Write the header and all data for a portable bitmap.  This
       function       combines       pbmwritepbminit()       and
       pbmwritepbmrow().

SEE ALSO
       libpgm(3), libppm(3), libpnm(3)

AUTHOR
       Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer.




















                                                                3


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