home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Graphics / ToyViewer-2.6a / src / common.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-22  |  3.4 KB  |  134 lines

  1. /*
  2.     common.h    image independent information
  3. */
  4.  
  5. #ifndef _COMMON_h_
  6. #define _COMMON_h_
  7.  
  8. #include <appkit/graphics.h>
  9. #include <stdio.h>
  10.  
  11. #define  Err_OPEN    1
  12. #define  Err_FORMAT    2
  13. #define  Err_MEMORY    3
  14. #define  Err_SHORT    4
  15. #define  Err_ILLG    5
  16. #define  Err_IMPLEMENT    6
  17. #define  Err_SAVE    7
  18. #define  Err_SAV_IMPL    8
  19. #define  Err_EPS_IMPL    9
  20. #define  Err_EPS_ONLY    10
  21. #define  Err_OPR_IMPL    11
  22. #define  Err_NOFILE    12
  23. #define  Err_FLT_EXEC    13
  24.  
  25. #define  Type_none    -1
  26. #define  Type_other    0    /* Filter service */
  27. #define  Type_tiff    1
  28. #define  Type_eps    2
  29. #define  Type_gif    3
  30. #define  Type_bmp    4
  31. #define  Type_ppm    5
  32. #define  Type_pcd    6
  33. #define  Type_user    0x11    /* User-specified pipe */
  34. #define  Type_pcx    0x12
  35. #define  Type_mag    0x13
  36. #define  Type_jpg    0x14
  37. #define  Type_xbm    0x15
  38. #define  Type_jbg    0x16
  39. #define  Type_png    0x17
  40. #define  viaPipe(t)    ((t) > 0 && (0xf0 & (t)))
  41.  
  42. #define  isAlphaOpaque(x)    ((x) >= 255)
  43. #define  isAlphaTransp(x)    ((x) < 255)
  44. #define  AlphaOpaque        255
  45. #define  AlphaTransp        0
  46. #define  Bright255(r, g, b)    (((r)*30 + (g)*59 + (b)*11 + 50) / 100)
  47.  
  48. #define  toyviewerTAB    "filters"
  49. #define  toyviewerRC    ".toyviewerrc"
  50.  
  51. #define  RED    0
  52. #define  GREEN    1
  53. #define  BLUE    2
  54. #define  ALPHA    3
  55. #define  FIXcount    256
  56. #define  MAXPLANE    5
  57.  
  58. /* Operations */
  59. #define  NoOperation    0
  60. #define  Rotation    1
  61. #define  Horizontal    2
  62. #define  Vertical    3
  63. #define  Clip        4
  64. #define  Negative    5
  65. #define  NewBitmap    6
  66. #define  Monochrome    7
  67. #define  Gray2Bits    8
  68. #define  BiLevel    9
  69. #define  Brightness    10
  70. #define  ColorTone    11
  71. #define  Reduction    12
  72. #define  ColorChange    13
  73. #define  Enhance    14
  74. #define  Emboss        15
  75. #define  RandomPttn    16
  76. #define  ResizeEPS    17
  77. #define  SoftFrame    18
  78. #define  Posterize    19
  79. #define  CutDown    20
  80.  
  81. #define  MAXWidth    4096    /* †Łˋþ⁄˛†£²ÿ⁄˛ˋ瘌”˙´ñˆ˝ */
  82. #define  MAX_COMMENT    256
  83. #define     MAXFILENAMELEN    512
  84.  
  85. typedef unsigned char    paltype[3];
  86.  
  87. typedef struct {
  88.     int    width, height;
  89.     short    xbytes;        /* ¥—¥⁄¥¨¿û/line */
  90.     short    palsteps;    /* colors of palette */
  91.     unsigned char    type;    /* Type_??? */
  92.     unsigned char    bits;
  93.     unsigned char    numcolors;    /* color elements without alpha */
  94.     BOOL    isplanar, alpha;
  95.     NXColorSpace    cspace;
  96.     paltype    *palette;
  97.     unsigned char    memo[MAX_COMMENT];
  98. } commonInfo;
  99. /* If ( commonInfo.alpha == YES && commonInfo.palette != NULL) then
  100.    the image has one transparent entry in the palette as GIF.
  101.    The index of transparence should be the last of the palette.
  102.  */
  103. /* Rule for "memo" string:
  104.     memo  :=  Dim [Kind] Attr{[,] Attr} : COMMENT
  105.     Dim    Ex. "560 x 300" or "560x300"
  106.     Kind    Ex. "jpg", "EPS", "GIF87a"
  107.     Attr    Ex. "16colors", "gray", "alpha", ...
  108.     Don't use ':' in Dim ,Kind, or Attr.
  109.     Format of comments in pnm, pxo, or pao:
  110.     [Attr{[,] Attr}] : COMMENT
  111. */
  112.  
  113. extern int get_short(FILE *);
  114. extern long get_long(FILE *);
  115. extern void put_short(int, FILE *);
  116. extern void put_long(long, FILE *);
  117. extern int byte_length(int, int);
  118. extern void errAlert(const char *, int);
  119. extern void warnAlert(const char *, int);
  120. extern void timedAlert(BOOL);
  121.  
  122. extern int optimalBits(unsigned char *, int);
  123. extern int howManyBits(paltype *, int);
  124. extern BOOL isGray(paltype *, int);
  125. extern int allocImage(unsigned char **, int, int, int, int);
  126. extern void expandImage(unsigned char **,
  127.     unsigned char *, paltype const *, int, int, BOOL, int);
  128. extern void packImage(unsigned char *, unsigned char *, int, int);
  129. extern void packWorkingImage(const commonInfo *, int,
  130.     unsigned char **, unsigned char **);
  131. extern paltype *copyPalette(paltype *, int);
  132.  
  133. #endif /* _COMMON_h_ */
  134.