logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

libpgm - libnetpbm functions to read and write PGM image files

Description

       These library functions are part of Netpbm(1).

   TYPESANDCONSTANTS
       Each gray should contain only the values between 0 and PGM_OVERALLMAXVAL.

       PGM_OVERALLMAXVAL  is the maximum value of a maxval in a PGM file.  PGM_MAXMAXVAL is the maximum value of
       a maxval in a PGM file that is compatible with the PGM format as it existed before  April  2000.   It  is
       also  the  maximum  value  of  a maxval that results in the minimum possible raster size for a particular
       image.  I.e an image with a maxval higher than PGM_MAXMAXVAL cannot be  read  or  generated  by  old  PGM
       processing programs and requires more file space.

       PGM_FORMAT   is  the format code for a Plain PGM format image file.  RPGM_FORMAT is the format code for a
       Raw PGM format image file.  PGM_TYPE  is the format type code for the PGM formats.  PGM_FORMAT_TYPE is  a
       macro  that  generates  code  to compute the format type code of a PBM or PGM format from the format code
       which is its argument.

   INITIALIZATIONpgm_init() is obsolete (at least since Netpbm 9.25 (March 2002)).  Use pm_proginit()  instead.

       pgm_init() is identical to pm_proginit.

   MEMORYMANAGEMENTpgm_allocarray() allocates an array of grays.

       pgm_allocrow() allocates a row of the given number of grays.

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

       pgm_freerow() frees a row of grays allocated with pgm_allocrow().

   READINGFILES
       If a function in this section is called on a PBM format file, it translates the PBM file into a PGM  file
       on  the  fly and functions as if it were called on the equivalent PGM file.  The format value returned by
       pgm_readpgminit() is, however, not translated.  It represents the actual format of the PBM file.

       pgm_readpgminit() reads the header of a PGM file, returning all  the  information  from  the  header  and
       leaving the file positioned just after the header.

       pgm_readpgmrow() reads a row of grays into the grayrow
        array.  format, cols, and maxval  are the values returned by pgm_readpgminit().

       pgm_readpgm()  reads  an  entire PGM image into memory, returning the allocated array as its return value
       and returning the information from the  header  as  rows,  cols,  and  maxval.   This  function  combines
       pgm_readpgminit(), pgm_allocarray(), and pgm_readpgmrow().

       pgm_readpgminit()  and  pgm_readpgm  abort  the program with a message to Standard Error if the PGM image
       header is not syntactically valid, including if it contains a number too large to be processed using  the
       system's normal data structures (to wit, a number that won't fit in a C 'int').

   WRITINGFILESpgm_writepgminit() writes the header for a PGM file and leaves it positioned just after the header.

       forceplain  is  a  logical  value that tells pgm_writepgminit()  to write a header for a plain PGM format
       file, as opposed to a raw PGM format file.

       pgm_writepgmrow() writes the row grayrow to a PGM  file.   For  meaningful  results,  cols,  maxval,  and
       forceplain must be the same as was used with pgm_writepgminit().

       pgm_writepgm()  write the header and all data for a PGM image.  This function combines pgm_writepgminit()
       and pgm_writepgmrow().

   MISCELLANEOUSpgm_nextimage()  positions  a  PGM  input  file  to  the  next  image  in  it  (so  that   a   subsequent
       pgm_readpgminit() reads its header).

       pgm_nextimage() is analogous to pbm_nextimage(), but works on PGM and PBM files.

       pgm_check()   checks  for the common file integrity error where the file is the wrong size to contain all
       the image data.

       pgm_check()  is analogous to pbm_check(), but works on PGM and PBM files.

Document Source

       This manual page was generated by the Netpbm tool 'makeman' from HTML source.  The  master  documentation
       is at

              http://netpbm.sourceforge.net/doc/libpgm.html

netpbm documentation                            08 September 2007           Usermanualforoldpgmfunctions(3)

Name

       libpgm - libnetpbm functions to read and write PGM image files

See Also

libpbm(1), libppm(1), libpnm(1)

Synopsis

#include<netpbm/pgm.h>voidpgm_init(int*argcP,char*argv[]);gray**pgm_allocarray(intcols,introws);gray*pgm_allocrow(intcols);voidpgm_freearray(gray**grays,introws);voidpgm_freerow(gray*grayrow);voidpgm_readpgminit(FILE*fp,int*colsP,int*rowsP,gray*maxvalP,int*formatP);voidpgm_readpgmrow(FILE*fp,gray*grayrow,intcols,graymaxval,intformat);gray**pgm_readpgm(FILE*fp,int*colsP,int*rowsP,gray*maxvalP);voidpgm_writepgminit(FILE*fp,intcols,introws,graymaxval,intforceplain);voidpgm_writepgmrow(FILE*fp,gray*grayrow,intcols,graymaxval,intforceplain);voidpgm_writepgm(FILE*fp,gray**grays,intcols,introws,graymaxval,intforceplain);voidpgm_writepgm(FILE*fp,gray**grays,intcols,introws,graymaxval,intforceplain);voidpgm_nextimage(FILE*file,int*consteofP);voidpgm_check(FILE*file,constenumpm_check_typecheck_type,constintformat,constintcols,constintrows,constintmaxval,enumpm_check_code*constretval);typedef...gray;#definePGM_MAXMAXVAL...#definePGM_OVERALLMAXVAL...#definePGM_FORMAT...#defineRPGM_FORMAT...#definePGM_TYPEPGM_FORMAT#definePGM_FORMAT_TYPE(format)...

See Also