home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / netpbma.zip / ppm / mitsu.h < prev    next >
C/C++ Source or Header  |  1993-10-04  |  4KB  |  135 lines

  1. /* static char SCCSid[] = "@(#)mitsu.h\t\t1.3\t(SPZ)\t3/11/92\n"; */
  2. #include <stdio.h>
  3. #define FALSE 0
  4. #define TRUE  1
  5. #define mytoupper(x) (islower(x) ? toupper(x) : (x))
  6.  
  7. #define HASHSIZE 2048
  8. #define myhash(x) ((PPM_GETR(x)*3 + PPM_GETG(x)*5 + PPM_GETB(x)*7) % HASHSIZE)
  9.  
  10. typedef struct hashinfo {
  11.         pixel     color;
  12.         long      flag;
  13.         struct hashinfo *next;
  14. } hashinfo;
  15.  
  16. struct mediasize {
  17.         char size;
  18.         int  maxcols, maxrows;
  19. };
  20.  
  21. #ifdef __STDC__
  22. static void lineputinit(int cols, int rows, int sharpness, int enlarge, int
  23.                         copy, struct mediasize medias);
  24. static void frametransferinit(int cols, int rows, int sharpness, int enlarge,
  25.                               int copy, struct mediasize medias);
  26. static void lookuptableinit(int sharpness, int enlarge, int copy,
  27.                             struct mediasize medias);
  28. static void lookuptabledata(int cols, int rows, int enlarge,
  29.                             struct mediasize medias);
  30. static void check_and_rotate(int cols, int rows, int enlarge,
  31.                              struct mediasize medias);
  32. static void * mymalloc(long bytes);
  33. #define CONST const
  34. #else /*__STDC__*/
  35. static int lineputinit();
  36. static int lookuptableinit();
  37. static int lookuptabledata();
  38. static int frametransferinit();
  39. static int check_and_rotate();
  40. static char *mymalloc();
  41. #define CONST
  42. #endif
  43.  
  44. #define cmd(arg)           fputc((arg), stdout)
  45. #define datum(arg)         fputc((char)(arg), stdout)
  46. #define data(arg,num)      fwrite((arg), sizeof(char), (num), stdout)
  47.  
  48. #define MAXLUTCOL   255
  49.  
  50. #define A4_MAXCOLS  1184
  51. #define A4_MAXROWS  1452
  52. #define A4S_MAXROWS 1754
  53. #define A_MAXCOLS   1216
  54. #define A_MAXROWS   1350
  55. #define AS_MAXROWS  1650
  56.  
  57. #define ONLINE         cmd('\021')
  58. #define CLRMEM         cmd('\033'), cmd('Z')
  59.  
  60. CONST struct mediasize MSize_User={' ',1184,1350};
  61. CONST struct mediasize MSize_A4  ={'0',1184,1452};
  62. CONST struct mediasize MSize_A   ={'1',1216,1350};
  63. CONST struct mediasize MSize_A4S ={'2',1184,1754};
  64. CONST struct mediasize MSize_AS  ={'3',1216,1650};
  65. #define MEDIASIZE(chr) cmd('\033'), cmd('#'), cmd('P'), cmd((chr).size)
  66.  
  67. #define HENLARGE(enl)  cmd('\033'), cmd('&'), cmd('P'), cmd(enl), cmd('\001')
  68. #define VENLARGE(enl)  cmd('\033'), cmd('&'), cmd('Q'), cmd(enl), cmd('\001')
  69. #define NOENLARGE '\001'
  70. #define ENLARGEx2 '\002'
  71. #define ENLARGEx3 '\003'
  72.  
  73. #define COLREVERSION(arg) cmd('\033'), cmd('&'), cmd('W'), cmd(arg)
  74. #define DONTREVERTCOLOR '0'
  75. #define REVERTCOLOR   '2'
  76.  
  77. #define NUMCOPY(num)   cmd('\033'), cmd('#'), cmd('C'), cmd((num) & 0xff)
  78.  
  79. #define HOFFINCH(off)  cmd('\033'), cmd('&'), cmd('S'), cmd((off) & 0xff)
  80. #define VOFFINCH(off)  cmd('\033'), cmd('&'), cmd('T'), cmd((off) & 0xff)
  81.  
  82. #define CENTERING(cen) cmd('\033'), cmd('&'), cmd('C'), cmd(cen)
  83. #define DONTCENTER '0'
  84. #define DOCENTER   '1'
  85.  
  86. #define TRANSFERFORMAT(fmt) cmd('\033'), cmd('&'), cmd('A'), cmd(fmt)
  87. #define FRAMEORDER  '0'
  88. #define LINEORDER   '1'
  89. #define LOOKUPTABLE '3'
  90.  
  91. #define COLORSYSTEM(cs) cmd('\033'), cmd('&'), cmd('I'), cmd(cs)
  92. #define RGB '0'
  93. #define YMC '1'
  94.  
  95. #define SHARPNESS(spn) cmd('\033'), cmd('#'), cmd('E'), cmd(spn)
  96. #define SP_USER ' '
  97. #define SP_NONE '0'
  98. #define SP_LOW  '1'
  99. #define SP_MIDLOW '2'
  100. #define SP_MIDHIGH '3'
  101. #define SP_HIGH '4'
  102.  
  103. #define COLORDES(col) cmd('\033'), cmd('C'), cmd(col)
  104. #define RED   '1'
  105. #define GREEN '2'
  106. #define BLUE  '3'
  107. #define YELLOW  '1'
  108. #define MAGENTA '2'
  109. #define CYAN    '3'
  110.  
  111. #define HPIXELS(hpix) cmd('\033'), cmd('&'), cmd('H'),\
  112.                                                         cmd(((hpix) >> 8) & 0xff), cmd((hpix) & 0xff)
  113. #define VPIXELS(vpix) cmd('\033'), cmd('&'), cmd('V'),\
  114.                                                         cmd(((vpix) >> 8) & 0xff), cmd((vpix) & 0xff)
  115. #define HPIXELSOFF(hoff) cmd('\033'), cmd('&'), cmd('J'),\
  116.                                                         cmd(((hoff) >> 8) & 0xff), cmd((hoff) & 0xff)
  117. #define VPIXELSOFF(voff) cmd('\033'), cmd('&'), cmd('K'),\
  118.                                                         cmd(((voff) >> 8) & 0xff), cmd((voff) & 0xff)
  119.  
  120. #define GRAYSCALELVL(lvl) cmd('\033'), cmd('#'), cmd('L'), cmd(lvl)
  121. #define BIT_6 '\006'
  122. #define BIT_8 '\010'
  123.  
  124. #define LOADLOOKUPTABLE cmd('\033'), cmd('&'), cmd('L')
  125. #define DONELOOKUPTABLE cmd('\004')
  126.  
  127. #define ROTATEIMG(rot)  cmd('\033'), cmd('#'), cmd('R'), cmd(rot)
  128. #define DONTROTATE '0'
  129. #define DOROTATE   '1'
  130.  
  131. #define DATASTART cmd('\033'), cmd('O')
  132. #define PRINTIT cmd('\014')
  133. #define OFFLINE cmd('\023')
  134.  
  135.