home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / netpbma.zip / Netpbm.programming < prev    next >
Text File  |  1993-11-15  |  3KB  |  59 lines

  1. This file is an attempt to give some basic guide lines for those
  2. who wish to write new Netpbm filters. Since Netpbm is intended to
  3. be portable to many platforms, it is absolutely necessary to stick
  4. to these when programming. Most of these rules were set up by Jef
  5. Poskanzer when he wrote Pbmplus, though some have come up more
  6. recently.
  7.  
  8. * Your new filter must belong to one of the four Netpbm formats,
  9.   i.e. pbm, pgm, ppm or pnm. They are defined as follows:
  10.   pbm: Bitmaps only, i.e. a pixel is either black or white.
  11.   pgm: Gray scales, i.e. a pixel can have any value between black
  12.        and white, but no colours.
  13.   ppm: Colour images. Note that Netpbm does not support the use of
  14.        look up tables.
  15.   pnm: A facility able to create or read more than one of the formats
  16.        above. Note that all pgm filters can automatically read pbm
  17.        images, and that all ppm filters can automatically read both
  18.        pbm and pgm files. A pnm utility does more than this, its action
  19.        depends on the type of the input file. E.g. the pnmtotiff utility
  20.        creates a bitmap TIFF file when it reads a pbm file on its input,
  21.        a gray scale TIFF files when it reads a pgm file on its input, etc.
  22.        ppmtogif on the other hand treats a pbm file on its input exactly
  23.        as if it were a ppm file with only the colours black and white.
  24.   Decide which one of these formats your filter belongs to.
  25.  
  26. * If you want to use global variables or global functions in your filter,
  27.   make them static, so that they won't cause problems to other filters
  28.   when you compile a merged binary (see the Makefile).
  29.  
  30. * So far, all filters are written in K&R style C, but with prototypes
  31.   for both K&R C and ANSI C. The ARGS macro (defined in pbmplus.h) helps
  32.   you to write prototypes. You can use it like this:
  33.   int my_function ARGS((int a, double b, char c));
  34.  
  35. * Include pbm.h, pgm.h, ppm.h, or pnm.h (only one of them!). Don't include
  36.   files like stdio.h, stdlib.h etc. These should be included through
  37.   pbmplus.h, which in turn is included by p?m.h (i.e. pbm.h, pgm.h, ppm.h,
  38.   or pnm.h). You may need to include math.h though.
  39.  
  40. * Declare main as: int main(argc, argv), not void! VMS won't compile
  41.   void main().
  42.  
  43. * Always start the code in main() with a call to p?m_init().
  44.  
  45. * All input and output of pbm format files must go through the library
  46.   routines. This ensures compatibility, error checking, correct byte
  47.   order etc.
  48.  
  49. * Use pm_error() and pm_message() for error messages and other messages.
  50.  
  51. * Don't forget to write a proper manual page!
  52.  
  53. The easiest way to write your own facility, is to take an existing one,
  54. similar to the want you want to write, and to modify it. This saves a
  55. lot of time, and ensures conformity with the rules stated above.
  56.  
  57. Oliver Trepte, November 15th, 1993
  58. oliver@fysik4.kth.se
  59.