home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / NETWORK / netpbm_src.lzh / NETPBM / PGM / pgm.h < prev    next >
Text File  |  1996-11-18  |  2KB  |  56 lines

  1. /* pgm.h - header file for libpgm portable graymap library
  2. */
  3.  
  4. #ifndef _PGM_H_
  5. #define _PGM_H_
  6.  
  7. #include "pbm.h"
  8.  
  9. #ifdef PGM_BIGGRAYS
  10. typedef unsigned short gray;
  11. #define PGM_MAXMAXVAL 65535
  12. #else /*PGM_BIGGRAYS*/
  13. typedef unsigned char gray;
  14. #define PGM_MAXMAXVAL 255
  15. #endif /*PGM_BIGGRAYS*/
  16.  
  17.  
  18. /* Magic constants. */
  19.  
  20. #define PGM_MAGIC1 'P'
  21. #define PGM_MAGIC2 '2'
  22. #define RPGM_MAGIC2 '5'
  23. #define PGM_FORMAT (PGM_MAGIC1 * 256 + PGM_MAGIC2)
  24. #define RPGM_FORMAT (PGM_MAGIC1 * 256 + RPGM_MAGIC2)
  25. #define PGM_TYPE PGM_FORMAT
  26.  
  27.  
  28. /* Macro for turning a format number into a type number. */
  29.  
  30. #define PGM_FORMAT_TYPE(f) ((f) == PGM_FORMAT || (f) == RPGM_FORMAT ? PGM_TYPE : PBM_FORMAT_TYPE(f))
  31.  
  32.  
  33. /* Declarations of routines. */
  34.  
  35. void pgm_init ARGS(( int* argcP, char* argv[] ));
  36.  
  37. #define pgm_allocarray( cols, rows ) ((gray**) pm_allocarray( cols, rows, sizeof(gray) ))
  38. #define pgm_allocrow( cols ) ((gray*) pm_allocrow( cols, sizeof(gray) ))
  39. #define pgm_freearray( grays, rows ) pm_freearray( (char**) grays, rows )
  40. #define pgm_freerow( grayrow ) pm_freerow( (char*) grayrow )
  41.  
  42. gray** pgm_readpgm ARGS(( FILE* file, int* colsP, int* rowsP, gray* maxvalP ));
  43. void pgm_readpgminit ARGS(( FILE* file, int* colsP, int* rowsP, gray* maxvalP, int* formatP ));
  44. void pgm_readpgmrow ARGS(( FILE* file, gray* grayrow, int cols, gray maxval, int format ));
  45.  
  46. void pgm_writepgm ARGS(( FILE* file, gray** grays, int cols, int rows, gray maxval, int forceplain ));
  47. void pgm_writepgminit ARGS(( FILE* file, int cols, int rows, gray maxval, int forceplain ));
  48. void pgm_writepgmrow ARGS(( FILE* file, gray* grayrow, int cols, gray maxval, int forceplain ));
  49.  
  50. extern gray pgm_pbmmaxval;
  51. /* This is the maxval used when a PGM program reads a PBM file.  Normally
  52. ** it is 1; however, for some programs, a larger value gives better results
  53. */
  54.  
  55. #endif /*_PGM_H_*/
  56.