home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / tiff / imag.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-02  |  5.0 KB  |  144 lines

  1. /* imag.h - useful declarations for doing imaging
  2.  *
  3.  * made 88-10-31
  4.  */
  5.  
  6. /*************************** #define's ************************/
  7.  
  8.  
  9. /* TAG FIELD INDICES: (not to be confused with actual tag values -- see
  10.  * tiff.h for those).  Also note that I only need define the things that
  11.  * I currently care about, to save a little space.
  12.  *
  13.  * this must be kept in numerical order by tag (see tiff.h), as of 88-10-12,
  14.  * since I am writing them out in the order they appear in the IMAG array.
  15.  */
  16. #define X_NEWSUBFILETYPE        0
  17. #define X_IMAGEWIDTH            1
  18. #define X_IMAGELENGTH            2
  19. #define X_BITSPERSAMPLE            3
  20. #define X_COMPRESSION            4
  21. #define X_PHOTOMETRICINTERP        5
  22. #define X_STRIPOFFSETS            6
  23. #define X_SAMPLES                7    /* SamplesPerPixel */
  24. #define X_ROWSPERSTRIP            8
  25. #define X_STRIPBYTECOUNTS        9
  26. #define X_XRESOLUTION            10
  27. #define X_YRESOLUTION            11
  28. #define X_PLANAR                12    /* PlanarConfiguration */
  29. #define    X_GRAYUNIT                13
  30. #define    X_GRAYCURVE                14
  31. #define X_RESOLUTIONUNIT        15
  32. #define X_COLORCURVES            16
  33. #define    X_PREDICTOR                17    /* 88-09-19 */
  34.  
  35. #define NTFIELDS                18    /* KEEP THIS CURRENT!!! (one more than largest value) */
  36.  
  37. /* shorthand ways of getting to field data.  Note:  assumes something has
  38.  * converted if necessary to my standard data type for that field.  See
  39.  * tiff.c for the code that determines the current standard type for each field.
  40.  */
  41. #define dwNewSubfileType            tf[X_NEWSUBFILETYPE].val.Tdword    /* 88-09-12 */
  42.  
  43. #define iImageWidth                    tf[X_IMAGEWIDTH].val.Tword[0]
  44. #define iImageLength                tf[X_IMAGELENGTH].val.Tword[0]
  45. #define iBitsPerSample                tf[X_BITSPERSAMPLE].val.Tword[0]    /* assumes BitsPerSample values are equal! */
  46. #define iSamples                    tf[X_SAMPLES].val.Tword[0]            /* SamplesPerPixel */
  47. #define iCompression                tf[X_COMPRESSION].val.Tword[0]
  48. #        define PACKINTOBYTES    1
  49. #        define CCITT1D            2
  50. #        define COMPR5            5
  51. #        define TIFFPACKBITS        32773    /* MacPaint scheme in TIFF file */
  52. #define iPhotometricInterpretation    tf[X_PHOTOMETRICINTERP].val.Tword[0]
  53. #        define WHITEZERO    0
  54. #        define BLACKZERO    1
  55. #        define TIFFRGB        2
  56. #define hSTRIPOffsets                tf[X_STRIPOFFSETS].Thandle
  57. #define iRowsPerStrip                tf[X_ROWSPERSTRIP].val.Tword[0]
  58. #define fXResolution                tf[X_XRESOLUTION].val.Tfloat
  59. #define fYResolution                tf[X_YRESOLUTION].val.Tfloat
  60. #define iPlanar                        tf[X_PLANAR].val.Tword[0]
  61. #        define CHUNKY    1    /* RGB RGB RGB */
  62. #        define PLANAR    2    /* RRR GGG BBB, in separate planes */
  63. #define    iGrayUnit                    tf[X_GRAYUNIT].val.Tword[0]
  64. #define    hGrayCurve                    tf[X_GRAYCURVE].Thandle
  65. #define iResolutionUnit                tf[X_RESOLUTIONUNIT].val.Tword[0]
  66. #        define RES_UNIT_NO_UNIT            1
  67. #        define RES_UNIT_INCH            2
  68. #        define RES_UNIT_CM                3
  69. #define hStripByteCounts            tf[X_STRIPBYTECOUNTS].Thandle
  70. #define hColorCurves                tf[X_COLORCURVES].Thandle
  71. #define iPredictor                    tf[X_PREDICTOR].val.Tword[0]
  72. #        define PREDICTOR_NONE            1
  73. #        define PREDICTOR_HDIFF            2
  74.  
  75. /* shorthands for existence flags
  76.  */
  77. #define eNewSubfileType                tf[X_NEWSUBFILETYPE].Texists
  78. #define eImageWidth                    tf[X_IMAGEWIDTH].Texists
  79. #define eImageLength                tf[X_IMAGELENGTH].Texists
  80. #define eSamples                    tf[X_SAMPLES].Texists
  81. #define eCompression                tf[X_COMPRESSION].Texists
  82. #define ePhotometricInterpretation    tf[X_PHOTOMETRICINTERP].Texists
  83. #define eStripOffsets                tf[X_STRIPOFFSETS].Texists
  84. #define eXResolution                tf[X_XRESOLUTION].Texists
  85. #define eYResolution                tf[X_YRESOLUTION].Texists
  86. #define ePlanar                        tf[X_PLANAR].Texists
  87. #define    eGrayUnit                    tf[X_GRAYUNIT].Texists
  88. #define    eGrayCurve                    tf[X_GRAYCURVE].Texists
  89. #define eResolutionUnit                tf[X_RESOLUTIONUNIT].Texists
  90. #define eStripByteCounts            tf[X_STRIPBYTECOUNTS].Texists
  91. #define    eColorCurves                tf[X_COLORCURVES].Texists
  92. #define ePredictor                    tf[X_PREDICTOR].Texists
  93.  
  94. /********************* structure definitions *******************/
  95.  
  96.  
  97. /* Tiff Field Structure.  An array of these things is the main part of
  98.  * the IMAG structure, below.
  99.  */
  100. typedef struct {
  101.     BOOL    Texists;
  102.     BOOL    Talloc;        /* true if Thandle is being used */
  103.     WORD    Ttag;
  104.     WORD    Ttype;
  105.     DWORD    Tlength;
  106.     HANDLE    Thandle;    /* for things > 4 bytes, except for TIFF RATIONAL */
  107.     union {
  108.         BYTE    Tbyte[4];
  109.         char    Tchar[4];
  110.         WORD    Tword[2];    /* from TIFF SHORT */
  111.         short    Tsigned[2];    /* from TIFF SIGNED */
  112.         DWORD    Tdword;        /* from TIFF LONG */
  113.         float    Tfloat;        /* from TIFF RATIONAL */
  114.     } val;
  115.     DWORD    Tentryoffset;    /* file/memory offset of the TIFF directory
  116.                              * entry.
  117.                              */
  118. } TFIELD;
  119.  
  120.  
  121. /* structure containing all available information about an image
  122.  * this structure is never to be written to disk directly; use the 
  123.  * TIFF routines.
  124.  */
  125. typedef struct {
  126.     WORD    iFileType;
  127. #define            INTELTIFF     (0x4949)
  128. #define            MOTOROLATIFF (0x4d4d)
  129.  
  130.     WORD    iVersion;
  131. #define            VERSION42    42
  132.  
  133.     /* THE REAL TIFF FIELDS:
  134.      */
  135.     TFIELD    tf[NTFIELDS];
  136.  
  137. } IMAG, FAR * LPIMAG;
  138.  
  139. /************************** function declarations *************************/
  140.  
  141. void InitImag ARGS((IMAG *));
  142. void CloseImag ARGS((IMAG *));
  143. RC TfStore ARGS((WORD, WORD, DWORD, LPSTR, TFIELD *));
  144. RC TfCopy ARGS((IMAG *, IMAG *, WORD));