home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1430 / display.h next >
C/C++ Source or Header  |  1990-12-28  |  2KB  |  110 lines

  1.  
  2. #include <stdio.h>
  3. #include <ctype.h>
  4. #include <math.h>
  5. #ifdef vms
  6. #define random rand
  7. #define popen(command,mode)  (FILE *) exit(1)
  8. #else
  9. #include <malloc.h>
  10. #include <memory.h>
  11.  
  12. double
  13.   strtod();
  14.  
  15. long
  16.   strtol(),
  17.   time();
  18. #endif
  19. /*
  20.   Define declarations for the Display program.
  21. */
  22. #ifndef False
  23. #define False  0
  24. #endif
  25. #define GammaCorrect(color,gamma)  \
  26.   (pow((double) color/MaxRgb,1.0/gamma)*MaxRgb)
  27. #define Intensity(color) \
  28.   (((color).red*77+(color).green*150+(color).blue*29) >> 8)
  29. #define Max(x,y)  (((x) > (y)) ? (x) : (y))
  30. #define MaxColormapSize  4096
  31. #define MaxImageSize  (4096*4096)
  32. #define MaxRgb  255
  33. #define Min(x,y)  (((x) < (y)) ? (x) : (y))
  34. #ifndef True
  35. #define True  1
  36. #endif
  37. /*
  38.   Image Id's
  39. */
  40. #define UnknownId  0
  41. #define XImagerId  1
  42. /*
  43.   Image classes:
  44. */
  45. #define UnknownClass  0
  46. #define DirectClass  1
  47. #define PseudoClass  2
  48. /*
  49.   Image compression algorithms:
  50. */
  51. #define UnknownCompression  0
  52. #define NoCompression  1
  53. #define RunlengthEncodedCompression  2
  54. #define QEncodedCompression  3
  55.  
  56. /*
  57.   Typedef declarations for the Display program.
  58. */
  59. typedef struct _ColorPacket
  60. {
  61.   unsigned char
  62.     red,
  63.     green,
  64.     blue;
  65.  
  66.   unsigned short
  67.     index;
  68. } ColorPacket;
  69.  
  70. typedef struct _RunlengthPacket
  71. {
  72.   unsigned char
  73.     red,
  74.     green,
  75.     blue,
  76.     length;
  77.  
  78.   unsigned short
  79.     index;
  80. } RunlengthPacket;
  81.  
  82. typedef struct _Image
  83. {
  84.   FILE
  85.     *file;
  86.  
  87.   char
  88.     filename[256];
  89.  
  90.   unsigned int
  91.     id,
  92.     class,
  93.     colors,
  94.     packets,
  95.     compression,
  96.     columns,
  97.     rows,
  98.     scene,
  99.     channel;
  100.  
  101.   char
  102.     *comments;
  103.  
  104.   ColorPacket
  105.     *colormap;
  106.  
  107.   RunlengthPacket
  108.     *pixels;
  109. } Image;
  110.