home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / CDRom / PHOTOC12.LZX / src / photocdaga / hpcdtoppm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-11  |  5.0 KB  |  212 lines

  1. /* hpcdtoppm (Hadmut's pcdtoppm) v0.6
  2. *  Copyright (c) 1992, 1993, 1994 by Hadmut Danisch (danisch@ira.uka.de).
  3. *  Permission to use and distribute this software and its
  4. *  documentation for noncommercial use and without fee is hereby granted,
  5. *  provided that the above copyright notice appear in all copies and that
  6. *  both that copyright notice and this permission notice appear in
  7. *  supporting documentation. It is not allowed to sell this software in 
  8. *  any way. This software is not public domain.
  9. */
  10.  
  11.  
  12. /* NOTE: Don't use this file for compiling hpcdtoppm, it is heavily */
  13. /* modified.  (By me, Günther Röhrich)                              */
  14. /* EMAIL: Guenther@studbox.uni-stuttgart.de  */
  15.  
  16.  
  17. #include <stdio.h>
  18. #include <string.h>
  19. #include <ctype.h>
  20. #include "config.h"
  21.  
  22.  
  23.  
  24.  
  25.  
  26. /* Format definitions */
  27.  
  28. #define BaseW ((dim)768)
  29. #define BaseH ((dim)512)
  30.  
  31. #define SECSIZE 0x800
  32.  
  33. #define SeHead   2
  34. #define L_Head   (1+SeHead)
  35.  
  36. #define SeBase16 18
  37. #define L_Base16 (1+SeBase16)
  38.  
  39. #define SeBase4  72
  40. #define L_Base4  (1+SeBase4)
  41.  
  42. #define SeBase   288
  43. #define L_Base   (1+SeBase)
  44.  
  45.  
  46. #define neutrLum 128
  47. #define neutrCh1 156
  48. #define neutrCh2 137
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. /* Structures and definitions */
  57. struct _implane
  58.  {dim  mwidth,mheight,
  59.        iwidth,iheight;
  60.   uBYTE *im,*mp;
  61.  };
  62. typedef struct _implane implane;
  63.  
  64. #define nullplane ((implane *) 0)
  65.  
  66.  
  67.  
  68.  
  69.  
  70. struct _sizeinfo
  71.  {dim w,h;  /* Image Resolution */
  72.   dim rdhoff,rdhlen, rdvoff, rdvlen; /* Size of Image in Memory */
  73.   dim imhoff,imhlen, imvoff, imvlen; /* Real Size of Image */
  74.  };
  75. typedef struct _sizeinfo sizeinfo;
  76.  
  77.  
  78.  
  79.  
  80. /* Definitions for 64Base */
  81.  
  82. struct file32 { uBYTE x1,x2,x3,x4;};
  83. struct file16 { uBYTE x1,x2;};
  84. #define FILE32(x) ( (((uINT)x.x1)<<24) | (((uINT)x.x2)<<16) | (((uINT)x.x3)<<8) | (uINT)x.x4 )
  85. #define FILE16(x) ( (((uINT)x.x1)<<8) | (uINT)x.x2 )
  86.  
  87. struct ic_header {char ic_name[0x28];
  88.                   struct file16 val1;
  89.                   struct file16 val2;
  90.                   struct file32 off_descr;
  91.                   struct file32 off_fnames;
  92.                   struct file32 off_pointers;
  93.                   struct file32 off_huffman;
  94.                  };
  95.  
  96. struct ic_descr {struct file16 len;
  97.                  uBYTE  color;
  98.                  uBYTE  fill;  /* Don't know */
  99.                  struct file16 width;
  100.                  struct file16 height;
  101.                  struct file16 offset;
  102.                  struct file32 length;
  103.                  struct file32 off_pointers;
  104.                  struct file32 off_huffman;
  105.                 };
  106.  
  107.  
  108. struct ic_fname  {char fname[12];
  109.                   struct file32 size;
  110.                  };
  111.  
  112. struct ic_entry {struct file16 fno;
  113.                  struct file32 offset;
  114.                 };
  115.  
  116.  
  117.  
  118. enum   TURNS  { T_UNSPEC,T_NONE,T_RIGHT,T_LEFT,T_HEAD,T_AUTO };
  119. enum   SIZES  { S_UNSPEC,S_Base16,S_Base4,S_Base,S_4Base,S_16Base,S_64Base,S_Over,S_Contact };
  120. enum   OUTFOR { O_UNSPEC,O_PPM,O_PGM,O_DCOLOR,O_DGRAY, O_DOVER_COLOR, O_DOVER_GRAY, O_YCC};
  121. enum   CORR   { C_UNSPEC,C_LINEAR,C_DARK,C_BRIGHT };
  122.  
  123. enum   ERRORS { E_NONE,E_READ,E_WRITE,E_INTERN,E_ARG,E_OPT,E_MEM,E_HUFF, E_MAPFILE,
  124.                 E_SEQ,E_SEQ1,E_SEQ2,E_SEQ3,E_SEQ4,E_SEQ5,E_SEQ6,E_SEQ7,E_POS,E_IMP,E_OVSKIP,
  125.                 E_TAUTO,E_TCANT,E_SUBR,E_PRPAR,E_CONFIG,E_FOPEN, E_DISPLAY, E_PICNUM, E_ABORT };
  126.  
  127.  
  128.  
  129.  
  130.  
  131. /**** Macros ****/
  132.  
  133.  
  134.  
  135. #ifdef DEBUG
  136. #define RPRINT  {fprintf(stderr,"R-Position %x\n",bufpos);}
  137. #else
  138. #define RPRINT
  139. #endif
  140.  
  141. #define melde(x) {if (do_melde) fprintf(stderr,x);}
  142.  
  143.  
  144. #define READBUF   READ(sbuffer,sizeof(sbuffer))
  145. #define EREADBUF {if(READBUF < 1) error(E_READ);}
  146.  
  147. #define SKIP(p)  { if (SKIPn(p)) error(E_READ);}
  148. #define SKIPr(p) { if (SKIPn(p)) return(E_READ);}
  149.  
  150.  
  151. #define TRIF(x,u,o,a,b,c) ((x)<(u)? (a) : ( (x)>(o)?(c):(b)  ))
  152. #define xNORM(x) x=TRIF(x,0,255,0,x,255)
  153. #define NORM(x) { if(x<0) x=0; else if (x>255) x=255;}
  154.  
  155. #ifndef MIN
  156. #define MIN(a,b) (((a) < (b)) ? (a) : (b))
  157. #endif
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166. /* main.c */
  167. extern void         close_all(void);
  168.  
  169. extern char         *ppmname,*pcdname;
  170. extern sINT         do_overskip,monochrome,do_melde,do_crop,do_sharp,do_rep;
  171.  
  172.  
  173. extern void         SEEK(int);
  174. extern int          SKIPn(int);
  175. extern int          READ(uBYTE *,int);
  176. extern sINT         bufpos;
  177. extern enum OUTFOR  outfor;
  178. extern sINT         flvert,flhori;
  179. extern enum CORR    corrmode;
  180. extern uBYTE        sbuffer[SECSIZE];
  181.  
  182.  
  183. /* error.c */
  184. extern void         eerror(enum ERRORS,char *, int);
  185.  
  186.  
  187.  
  188. /* tools.c */
  189. extern void         interpolate(implane *);
  190. extern void         planealloc(implane *,dim,dim);
  191. extern enum ERRORS  readplain(sizeinfo *,int,implane *,implane *,implane *);
  192. extern void         druckeid(void);
  193.  
  194. /* Type definitions for output format drives, used in output.c and the drivers */
  195.  
  196. typedef void (OUT1PL)(FILE *,dim,dim, uBYTE *,sdim,sdim);
  197. typedef void (OUT3PL)(FILE *,dim,dim, uBYTE *,sdim,sdim, uBYTE *,sdim,sdim, uBYTE *,sdim,sdim); 
  198.  
  199. /* color.c */
  200. extern void         colconvert(sizeinfo *,implane *,implane *,implane *);
  201.  
  202.  
  203. /* ppm.c */
  204. extern OUT3PL       write_ppm;
  205. extern OUT1PL       write_pgm;
  206.  
  207. /* wrdisplay.c */
  208. extern OUT3PL write_dcolor;
  209. extern OUT3PL write_dover_color;
  210. extern OUT1PL write_dgray;
  211. extern OUT1PL write_dover_gray;
  212.