home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / netpbma.zip / pgm / pgm.h < prev    next >
C/C++ Source or Header  |  1996-11-10  |  2KB  |  61 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. #ifdef __EMX__
  33. #define srandom srand
  34. #define random rand
  35. #endif
  36.  
  37.  
  38. /* Declarations of routines. */
  39.  
  40. void pgm_init ARGS(( int* argcP, char* argv[] ));
  41.  
  42. #define pgm_allocarray( cols, rows ) ((gray**) pm_allocarray( cols, rows, sizeof(gray) ))
  43. #define pgm_allocrow( cols ) ((gray*) pm_allocrow( cols, sizeof(gray) ))
  44. #define pgm_freearray( grays, rows ) pm_freearray( (char**) grays, rows )
  45. #define pgm_freerow( grayrow ) pm_freerow( (char*) grayrow )
  46.  
  47. gray** pgm_readpgm ARGS(( FILE* file, int* colsP, int* rowsP, gray* maxvalP ));
  48. void pgm_readpgminit ARGS(( FILE* file, int* colsP, int* rowsP, gray* maxvalP, int* formatP ));
  49. void pgm_readpgmrow ARGS(( FILE* file, gray* grayrow, int cols, gray maxval, int format ));
  50.  
  51. void pgm_writepgm ARGS(( FILE* file, gray** grays, int cols, int rows, gray maxval, int forceplain ));
  52. void pgm_writepgminit ARGS(( FILE* file, int cols, int rows, gray maxval, int forceplain ));
  53. void pgm_writepgmrow ARGS(( FILE* file, gray* grayrow, int cols, gray maxval, int forceplain ));
  54.  
  55. extern gray pgm_pbmmaxval;
  56. /* This is the maxval used when a PGM program reads a PBM file.  Normally
  57. ** it is 1; however, for some programs, a larger value gives better results
  58. */
  59.  
  60. #endif /*_PGM_H_*/
  61.