home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Reference_Library / Devices / iffp / ilbm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-21  |  8.5 KB  |  254 lines

  1. /* 
  2.  *
  3.  * ilbm.h:    Definitions for IFFParse ILBM reader.
  4.  *
  5.  * 6/27/91
  6.  */
  7.  
  8. #ifndef IFFP_ILBM_H
  9. #define IFFP_ILBM_H
  10.  
  11. #ifndef IFFP_IFF_H
  12. #include "iffp/iff.h"
  13. #endif
  14.  
  15. #ifndef INTUITION_INTUITION_H
  16. #include <intuition/intuition.h>
  17. #endif
  18. #ifndef GRAPHICS_VIDEOCONTROL_H
  19. #include <graphics/videocontrol.h>
  20. #endif
  21.  
  22. #ifndef NO_PROTOS
  23. #include <clib/graphics_protos.h>
  24. #include <clib/intuition_protos.h>
  25. #include <clib/alib_protos.h>
  26. #endif
  27.  
  28. /*  IFF types we may encounter  */
  29. #define    ID_ILBM        MAKE_ID('I','L','B','M')
  30.  
  31. /* ILBM Chunk ID's we may encounter
  32.  * (see iffp/iff.h for some other generic chunks)
  33.  */
  34. #define    ID_BMHD        MAKE_ID('B','M','H','D')
  35. #define    ID_CMAP        MAKE_ID('C','M','A','P')
  36. #define    ID_CRNG        MAKE_ID('C','R','N','G')
  37. #define    ID_CCRT        MAKE_ID('C','C','R','T')
  38. #define    ID_GRAB        MAKE_ID('G','R','A','B')
  39. #define    ID_SPRT        MAKE_ID('S','P','R','T')
  40. #define    ID_DEST        MAKE_ID('D','E','S','T')
  41. #define    ID_CAMG        MAKE_ID('C','A','M','G')
  42.  
  43. /* Use this constant instead of sizeof(ColorRegister). */
  44. #define sizeofColorRegister  3
  45.  
  46. typedef WORD Color4;   /* Amiga RAM version of a color-register,
  47.           * with 4 bits each RGB in low 12 bits.*/
  48.  
  49. /* Maximum number of bitplanes storable in BitMap structure */
  50. #define MAXAMDEPTH 8
  51. #define MAXAMCOLORREG 32
  52.  
  53. /* Maximum planes we can save */
  54. #define MAXSAVEDEPTH 24
  55.  
  56. /* convert width to BytesPerRow */
  57. #define    BytesPerRow(w)    ((w) + 15 >> 4 << 1)
  58. #define BitsPerRow(w)    ((w) + 15 >> 4 << 4)
  59.  
  60. /* Flags that should be masked out of old 16-bit CAMG before save or use.
  61.  * Note that 32-bit mode id (non-zero high word) bits should not be twiddled
  62.  */
  63. #define BADFLAGS  (SPRITES|VP_HIDE|GENLOCK_AUDIO|GENLOCK_VIDEO)
  64. #define OLDCAMGMASK  (~BADFLAGS)
  65.  
  66.  
  67. /*  Masking techniques  */
  68. #define    mskNone            0
  69. #define    mskHasMask        1
  70. #define    mskHasTransparentColor    2
  71. #define    mskLasso        3
  72.  
  73. /*  Compression techniques  */
  74. #define    cmpNone            0
  75. #define    cmpByteRun1        1
  76.  
  77. #define RowBytes(w)    ((((w) + 15) >> 4) << 1)
  78.  
  79. /* ---------- BitMapHeader ---------------------------------------------*/
  80. /*  Required Bitmap header (BMHD) structure describes an ILBM */
  81. typedef struct {
  82.     UWORD    w, h;        /* Width, height in pixels */
  83.     WORD    x, y;        /* x, y position for this bitmap  */
  84.     UBYTE    nPlanes;    /* # of planes (not including mask) */
  85.     UBYTE    masking;    /* a masking technique listed above */
  86.     UBYTE    compression;    /* cmpNone or cmpByteRun1 */
  87.     UBYTE    reserved1;    /* must be zero for now */
  88.     UWORD    transparentColor;
  89.     UBYTE    xAspect, yAspect;
  90.     WORD    pageWidth, pageHeight;
  91. } BitMapHeader;
  92.  
  93. /* ---------- ColorRegister --------------------------------------------*/
  94. /* A CMAP chunk is a packed array of ColorRegisters (3 bytes each). */
  95. typedef struct {
  96.     UBYTE red, green, blue;   /* MUST be UBYTEs so ">> 4" won't sign extend.*/
  97.     } ColorRegister;
  98.  
  99. /* ---------- Point2D --------------------------------------------------*/
  100. /* A Point2D is stored in a GRAB chunk. */
  101. typedef struct {
  102.     WORD x, y;      /* coordinates (pixels) */
  103.     } Point2D;
  104.  
  105. /* ---------- DestMerge ------------------------------------------------*/
  106. /* A DestMerge is stored in a DEST chunk. */
  107. typedef struct {
  108.     UBYTE depth;   /* # bitplanes in the original source */
  109.     UBYTE pad1;      /* UNUSED; for consistency store 0 here */
  110.     UWORD planePick;   /* how to scatter source bitplanes into destination */
  111.     UWORD planeOnOff;   /* default bitplane data for planePick */
  112.     UWORD planeMask;   /* selects which bitplanes to store into */
  113.     } DestMerge;
  114.  
  115. /* ---------- SpritePrecedence -----------------------------------------*/
  116. /* A SpritePrecedence is stored in a SPRT chunk. */
  117. typedef UWORD SpritePrecedence;
  118.  
  119. /* ---------- Camg Amiga Viewport Mode ---------------------------------*/
  120. /* A Commodore Amiga ViewPort->Modes is stored in a CAMG chunk. */
  121. /* The chunk's content is declared as a LONG. */
  122. typedef struct {
  123.    ULONG ViewModes;
  124.    } CamgChunk;
  125.  
  126. /* ---------- CRange cycling chunk -------------------------------------*/
  127. #define RNG_NORATE  36   /* Dpaint uses this rate to mean non-active */
  128. /* A CRange is store in a CRNG chunk. */
  129. typedef struct {
  130.     WORD  pad1;              /* reserved for future use; store 0 here */
  131.     WORD  rate;      /* 60/sec=16384, 30/sec=8192, 1/sec=16384/60=273 */
  132.     WORD  active;     /* bit0 set = active, bit 1 set = reverse */
  133.     UBYTE low, high;   /* lower and upper color registers selected */
  134.     } CRange;
  135.  
  136. /* ---------- Ccrt (Graphicraft) cycling chunk -------------------------*/
  137. /* A Ccrt is stored in a CCRT chunk. */
  138. typedef struct {
  139.    WORD  direction;  /* 0=don't cycle, 1=forward, -1=backwards */
  140.    UBYTE start;      /* range lower */
  141.    UBYTE end;        /* range upper */
  142.    LONG  seconds;    /* seconds between cycling */
  143.    LONG  microseconds; /* msecs between cycling */
  144.    WORD  pad;        /* future exp - store 0 here */
  145.    } CcrtChunk;
  146.  
  147. /* If you are writing all of your chunks by hand,
  148.  * you can use these macros for these simple chunks.
  149.  */
  150. #define putbmhd(iff, bmHdr)  \
  151.     PutCk(iff, ID_BMHD, sizeof(BitMapHeader), (BYTE *)bmHdr)
  152. #define putgrab(iff, point2D)  \
  153.     PutCk(iff, ID_GRAB, sizeof(Point2D), (BYTE *)point2D)
  154. #define putdest(iff, destMerge)  \
  155.     PutCk(iff, ID_DEST, sizeof(DestMerge), (BYTE *)destMerge)
  156. #define putsprt(iff, spritePrec)  \
  157.     PutCk(iff, ID_SPRT, sizeof(SpritePrecedence), (BYTE *)spritePrec)
  158. #define putcamg(iff, camg)  \
  159.     PutCk(iff, ID_CAMG, sizeof(CamgChunk),(BYTE *)camg)
  160. #define putcrng(iff, crng)  \
  161.     PutCk(iff, ID_CRNG, sizeof(CRange),(BYTE *)crng)
  162. #define putccrt(iff, ccrt)  \
  163.     PutCk(iff, ID_CCRT, sizeof(CcrtChunk),(BYTE *)ccrt)
  164.  
  165. #ifndef NO_PROTOS
  166. /* unpacker.c */
  167. BOOL unpackrow(BYTE **pSource, BYTE **pDest, WORD srcBytes0, WORD dstBytes0);
  168.  
  169. /* packer.c */
  170. LONG packrow(BYTE **pSource, BYTE **pDest, LONG rowSize);
  171.  
  172. /* ilbmr.c  ILBM reader routines */
  173. LONG loadbody(struct IFFHandle *iff, struct BitMap *bitmap,
  174.         BitMapHeader *bmhd);
  175. LONG loadbody2(struct IFFHandle *iff, struct BitMap *bitmap, 
  176.         BYTE *mask, BitMapHeader *bmhd, 
  177.         BYTE *buffer, ULONG bufsize);
  178. LONG loadcmap(struct IFFHandle *, WORD *colortable, USHORT *pNcolors);
  179. LONG getcolors(struct ILBMInfo *ilbm);
  180. void freecolors(struct ILBMInfo *ilbm);
  181. LONG alloccolortable(struct ILBMInfo *ilbm);
  182. ULONG getcamg(struct ILBMInfo *ilbm);
  183.  
  184. /* ilbmw.c  ILBM writer routines */
  185. long initbmhd(BitMapHeader *bmhd, struct BitMap *bitmap,
  186.               WORD masking, WORD compression, WORD transparentColor,
  187.               WORD width, WORD height, WORD pageWidth, WORD pageHeight,
  188.               ULONG modeid);
  189. long putcmap(struct IFFHandle *iff,APTR colortable,UWORD ncolors,UWORD bitspergun);
  190. long putbody(struct IFFHandle *iff, struct BitMap *bitmap,
  191.         BYTE *mask, BitMapHeader *bmHdr,
  192.         BYTE *buffer, LONG bufsize);
  193.  
  194. /* getdisplay.c (used to load a display) */
  195. LONG showilbm(struct ILBMInfo *ilbm, UBYTE *filename);
  196. void unshowilbm(struct ILBMInfo *ilbm);
  197. LONG createdisplay(struct ILBMInfo *);
  198. void deletedisplay(struct ILBMInfo *);
  199. LONG getdisplay(struct ILBMInfo *);
  200. void freedisplay(struct ILBMInfo *);
  201.  
  202. /* getbitmap.c (used if just loading brush or bitmap) */
  203. LONG createbrush(struct ILBMInfo *);
  204. void deletebrush(struct ILBMInfo *);
  205. LONG getbitmap(struct ILBMInfo *);
  206. void freebitmap(struct ILBMInfo *);
  207.  
  208. /* screen.c (opens 1.3 or 2.0 screen) */
  209. struct Screen *openidscreen(struct ILBMInfo *,SHORT,SHORT,SHORT,ULONG);
  210. struct Window *opendisplay(struct ILBMInfo *,SHORT,SHORT,SHORT,ULONG);
  211. ULONG  modefallback(ULONG, SHORT, SHORT, SHORT);
  212. void clipit(SHORT wide, SHORT high, struct Rectangle *spos,
  213.     struct Rectangle *dclip, struct Rectangle *txto,
  214.     struct Rectangle *stdo,struct Rectangle *maxo,
  215.     struct Rectangle * uclip);
  216. void closedisplay(struct ILBMInfo *);
  217. void modeErrorMsg(ULONG,ULONG);
  218.  
  219. /* loadilbm.c */
  220. LONG loadbrush(struct ILBMInfo *ilbm, UBYTE *filename);
  221. void unloadbrush(struct ILBMInfo *ilbm);
  222.  
  223. LONG queryilbm(struct ILBMInfo *ilbm, UBYTE *filename);
  224.  
  225. LONG loadilbm(struct ILBMInfo *ilbm, UBYTE *filename);
  226. void unloadilbm(struct ILBMInfo *ilbm);
  227.  
  228. /* saveilbm.c */
  229. LONG screensave(struct ILBMInfo *ilbm,
  230.             struct Screen *scr,
  231.             struct Chunk *chunklist1, struct Chunk *chunklist2,
  232.             UBYTE *filename);
  233.  
  234. LONG saveilbm(struct ILBMInfo *ilbm,
  235.         struct BitMap *bitmap, ULONG modeid,
  236.         WORD width, WORD height, WORD pagewidth, WORD pageheight,
  237.         APTR colortable, UWORD count, UWORD bitspergun,
  238.                 WORD masking, WORD transparentColor,
  239.         struct Chunk *chunklist1, struct Chunk *chunklist2,
  240.         UBYTE *filename);
  241.  
  242.  
  243. /* screendump.c (print screen or brush) */
  244. int screendump(struct Screen *scr,
  245.      UWORD srcx, UWORD srcy, UWORD srcw, UWORD srch,
  246.      LONG destcols, UWORD special);
  247.  
  248. /* bmprintc.c (write C source for ILBM) */
  249. void BMPrintCRep(struct BitMap *bm, FILE *fp, UBYTE *name, UBYTE *fmt);  
  250.  
  251. #endif /* NO_PROTOS */
  252.  
  253. #endif /* IFFP_ILBM_H */
  254.