home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 460.lha / 3DPlot_v2.0 / sources / ILBM_Lib.h < prev    next >
C/C++ Source or Header  |  1991-01-04  |  23KB  |  660 lines

  1.             /* C Include File for the dissidents ilbm.library */
  2.     /* Set your editor's TAB width to 3 for a ledgible reproduction */
  3.  
  4.     /* This file is meant to replace all IFF include files for ILBM and
  5.         ANIM applications using the ilbm.library */
  6.  
  7. /* #define FDwAT */
  8.  
  9. #ifndef ILBMLIB_H
  10. #define ILBMLIB_H
  11.  
  12. #ifndef GRAPHICS_GFX_H
  13. #include    <graphics/gfx.h>
  14. #endif
  15.  
  16. #ifndef INTUITION_INTUITION_H
  17. #include    <intuition/intuition.h>
  18. #endif
  19.  
  20. #ifndef LIBRARIES_DOS_H
  21. #include "libraries/dos.h"
  22. #endif
  23.  
  24.     /* ======================== Chunk IDs =============================== */
  25.  
  26. typedef LONG ID;    /* An ID is four printable ASCII chars but
  27.                          stored as a LONG for efficient copy & compare.*/
  28.  
  29. /* Four-character IDentifier builder.*/
  30. #define MakeID(a,b,c,d)  ( (LONG)(a)<<24L | (LONG)(b)<<16L | (c)<<8 | (d) )
  31.  
  32.     /* Standard group IDs.    A chunk with one of these IDs contains a
  33.         SubTypeID followed by zero or more chunks.*/
  34. #define FORM    MakeID('F','O','R','M')
  35. #define PROP    MakeID('P','R','O','P')
  36. #define LIST    MakeID('L','I','S','T')
  37. #define CAT        MakeID('C','A','T',' ')
  38. #define FILLER    MakeID(' ',' ',' ',' ')
  39.  
  40.     /* SubTypeIDs */
  41. #define ID_ILBM MakeID('I','L','B','M')
  42. #define ID_ANIM MakeID('A','N','I','M')
  43.  
  44.     /* ILBM Chunk IDs */
  45. #define ID_BMHD MakeID('B','M','H','D')
  46. #define ID_CMAP MakeID('C','M','A','P')
  47. #define ID_GRAB MakeID('G','R','A','B')
  48. #define ID_DEST MakeID('D','E','S','T')
  49. #define ID_SPRT MakeID('S','P','R','T')
  50. #define ID_CAMG MakeID('C','A','M','G')
  51. #define ID_BODY MakeID('B','O','D','Y')
  52. #define ID_CRNG MakeID('C','R','N','G')
  53. #define ID_CCRT  MakeID('C','C','R','T')
  54.  
  55.     /* ANIM Chunk IDs */
  56. #define ID_DLTA MakeID('D','L','T','A')
  57. #define ID_ANHD MakeID('A','N','H','D')
  58.  
  59. #define ID_ANFR MakeID('A','N','F','R')
  60. #define ID_MAHD MakeID('M','A','H','D')
  61. #define ID_MFHD MakeID('M','F','H','D')
  62. #define ID_CM16 MakeID('C','M','1','6')
  63. #define ID_ATXT MakeID('A','T','X','T')
  64. #define ID_PTXT MakeID('P','T','X','T')
  65.  
  66.  
  67.     /* =========================== Chunk ============================== */
  68.  
  69. /* All chunks start with a type ID and a count of the data bytes that
  70.    follow--the chunk's "logical size" or "data size". If that number is odd,
  71.    a 0 pad byte is written, too. */
  72. typedef struct {
  73.     ID      ckID;
  74.     LONG  ckSize;
  75.     } ChunkHeader;
  76.  
  77. typedef struct {
  78.     ID      ckID;
  79.     LONG  ckSize;
  80.     UBYTE ckData[ 1 /*REALLY: ckSize*/ ];
  81.     } Chunk;
  82.  
  83. /* Pass ckSize = szNotYetKnown to the writer to mean "compute the size".*/
  84. #define szNotYetKnown 0x80000001L
  85.  
  86. /* Need to know whether a value is odd so we can word-align.*/
  87. #define IS_ODD(a)   ((a) & 1)
  88.  
  89. /* This macro rounds up to an even number. */
  90. #define WordAlign(size)   ((size+1)&~1)
  91.  
  92. /* ALL CHUNKS MUST BE PADDED TO EVEN NUMBER OF BYTES.
  93.     ChunkPSize computes the total "physical size" of a padded chunk from
  94.     its "data size" or "logical size". */
  95. #define ChunkPSize(dataSize)  (WordAlign(dataSize) + sizeof(ChunkHeader))
  96.  
  97. /* The Grouping chunks (LIST, FORM, PROP, & CAT) contain concatenations of
  98.     chunks after a subtype ID that identifies the content chunks.
  99.     "FORM type XXXX", "LIST of FORM type XXXX", "PROPerties associated
  100.     with FORM type XXXX", or "conCATenation of XXXX".*/
  101. typedef struct {
  102.     ID      ckID;
  103.     LONG  ckSize;    /* this ckSize includes "grpSubID".*/
  104.     ID      grpSubID;
  105.     } GroupHeader;
  106.  
  107. typedef struct {
  108.     ID      ckID;
  109.     LONG  ckSize;
  110.     ID      grpSubID;
  111.     UBYTE grpData[ 1 /*REALLY: ckSize-sizeof(grpSubID)*/ ];
  112.     } GroupChunk;
  113.  
  114.  
  115.     /* ======== IFFP Status code return from the Lib Functions ========= */
  116. typedef LONG IFFP;
  117.     /* Status code result from an IFF procedure. A LONG, because must be
  118.         type compatible with ID for GetChunkHdr. Note that the error codes
  119.         below are not legal IDs. */
  120. #define IFF_OKAY    0L    /* Keep going...(not end of file, but we haven't found
  121.                             our requested FORM or an error yet). Note that the
  122.                             highest level routines use this to really mean that
  123.                             everything went well. (see LoadIFFToWindow) */
  124. #define END_MARK    -1L /* Encountered the end of a group (i.e. FORM, LIST, etc).
  125.                         The end of the entire file if you are at the top group.*/
  126. #define IFF_DONE    -2L /* Returns this when it has READ enough.
  127.                                 It means return to application. File is Okay. */
  128. #define DOS_ERROR -3L /* AmigaDOS Read or Write error. */
  129. #define NOT_IFF -4L  /* Not an IFF file. */
  130. #define NO_FILE -5L  /* Tried to open file, AmigaDOS didn't find it. */
  131. #define CLIENT_ERROR -6L
  132.                             /* Application made invalid request, for instance, write
  133.                             a negative size chunk. Also, out of memory error. */
  134. #define BAD_FORM    -7L /* A read routine complains about FORM semantics
  135.                             e.g. valid IFF file, but missing a required chunk such
  136.                             as an ILBM without a BMHD chunk. */
  137. #define SHORT_CHUNK -8L  /* Application asked IFFReadBytes to read more bytes
  138.                                  than are left in the chunk. Could be an applic. bug
  139.                                  or bad file. */
  140. #define BAD_IFF  -9L  /* mal-formed IFF file. Found half a chunk? A CAT with
  141.                                 a PROP in it? */
  142. #define IFF_NOTFOUND -10L
  143.                             /* The requested FORM not found within the IFF file
  144.              (Did you try to find an ILBM in an SMUS file?) */
  145. #define UNKNOWN_ERROR -11L  /* This error is unknown (i.e. not 1 of the
  146.                                  preceding). The default lib routines will never
  147.                                  return this. Your custom routines can use this
  148.                                 to signal your calling code that the custom
  149.                                 routine was responsible for terminating. */
  150.  
  151. /* This MACRO is used to RETURN immediately when a termination condition is
  152.     found. This is a pretty weird macro. It requires the caller to declare a
  153.     local "IFFP iffp" and assign it. This wouldn't work as a subroutine since
  154.     it returns for it's caller. */
  155. #define CheckIFFP()   { if (iffp != IFF_OKAY) return(iffp); }
  156.  
  157.  
  158.     /* =================== Context STRUCTURE ===================== */
  159.  
  160. typedef struct _GroupContext {
  161.     struct _GroupContext *parent; /* Containing group; NULL => whole file. */
  162.     ULONG    conUserData;                /* For the application's use */
  163.     BPTR    file;                            /* Byte-stream file handle. */
  164.     LONG    position;                    /* The context's logical file position. */
  165.     LONG    bound;                        /* File-absolute context bound
  166.                                                  or szNotYetKnown (writer only). */
  167.     ChunkHeader ckHdr;
  168.                             /* Current chunk header. ckHdr.ckSize = szNotYetKnown
  169.                              means we need to go back and set the size (writer only).
  170.                              See also Pseudo-IDs, above. */
  171.     ID    subtype;                        /* Group's subtype ID when reading. */
  172.     LONG    bytesSoFar;        /* # bytes read/written of current chunk's data. */
  173.     } GroupContext;
  174.  
  175. /* Computes the number of bytes not yet read from the current chunk, given
  176.     a group read context gc. */
  177. #define ChunkMoreBytes(gc)  ((gc)->ckHdr.ckSize - (gc)->bytesSoFar)
  178.  
  179.  
  180.     /* =================== BitMapHeader (BMHD Chunk) ================== */
  181.  
  182. typedef UBYTE Masking;        /* Choice of masking technique.*/
  183. #define mskNone         0
  184. #define mskHasMask        1
  185. #define mskHasTransparentColor    2
  186. #define mskLasso        3
  187.  
  188. typedef UBYTE Compression;    /* Choice of compression algorithm applied to
  189.      * each row of the source and mask planes. "cmpByteRun1" is the byte run
  190.      * encoding generated by Mac's PackBits. */
  191. #define cmpNone      0
  192. #define cmpByteRun1  1
  193.  
  194. /* Aspect ratios: The proper fraction xAspect/yAspect represents the pixel
  195.     aspect ratio pixel_width/pixel_height.
  196.  
  197.     For the 4 Amiga display modes:
  198.         320 x 200: 10/11  (these pixels are taller than they are wide)
  199.         320 x 400: 20/11
  200.         640 x 200:  5/11
  201.         640 x 400: 10/11        */
  202. #define x320x200Aspect 10
  203. #define y320x200Aspect 11
  204. #define x320x400Aspect 20
  205. #define y320x400Aspect 11
  206. #define x640x200Aspect    5
  207. #define y640x200Aspect 11
  208. #define x640x400Aspect 10
  209. #define y640x400Aspect 11
  210.  
  211. /* A BitMapHeader is stored in a BMHD chunk. */
  212. typedef struct {
  213.     UWORD w, h;         /* raster width & height in pixels */
  214.     WORD  x, y;         /* position for this image */
  215.     UBYTE nPlanes;        /* # source bitplanes */
  216.     Masking masking;        /* masking technique */
  217.     Compression compression;    /* compression algoithm */
  218.     UBYTE pad1;         /* UNUSED.  For consistency, put 0 here.*/
  219.     UWORD transparentColor;    /* transparent "color number" */
  220.     UBYTE xAspect, yAspect;    /* aspect ratio, a rational number x/y */
  221.     WORD  pageWidth, pageHeight;  /* source "page" size in pixels */
  222.     } BitMapHeader;
  223.  
  224.  
  225. /* RowBytes computes the number of bytes in a row, from the width in pixels.*/
  226. #define RowBytes(w)   (((w) + 15) >> 4 << 1)
  227.  
  228.  
  229.     /* ==================== ColorRegister ========================== */
  230.     /* A CMAP chunk is a packed array of ColorRegisters (3 bytes each). */
  231.  
  232. typedef struct {
  233.     UBYTE red, green, blue; /* MUST be UBYTEs so ">> 4" won't sign extend.*/
  234.     } ColorRegister;
  235.  
  236. /* Use this constant instead of sizeof(ColorRegister). */
  237. #define sizeofColorRegister  3
  238.  
  239. typedef WORD Color4;    /* Amiga RAM version of a color-register,
  240.                                 with 4 bits each RGB in low 12 bits.*/
  241.  
  242. /* Maximum number of bitplanes in RAM. Current Amiga max w/dual playfield. */
  243. #define MaxAmDepth    6
  244.  
  245. /* Maximum number of color regs in amiga colorTable */
  246. #define maxColorReg    32
  247.  
  248.  
  249.     /* ========================= Point2D ============================== */
  250.     /* A Point2D is stored in a GRAB chunk. */
  251.  
  252. typedef struct {
  253.     WORD x, y;        /* coordinates (pixels) */
  254.     } Point2D;
  255.  
  256.     /* ========================= DestMerge ============================ */
  257.     /* A DestMerge is stored in a DEST chunk. */
  258.  
  259. typedef struct {
  260.     UBYTE depth;    /* # bitplanes in the original source */
  261.     UBYTE pad1;     /* UNUSED; for consistency store 0 here */
  262.     UWORD planePick;    /* how to scatter source bitplanes into destination */
  263.     UWORD planeOnOff;    /* default bitplane data for planePick */
  264.     UWORD planeMask;    /* selects which bitplanes to store into */
  265.     } DestMerge;
  266.  
  267.     /* ====================== SpritePrecedence ======================== */
  268.     /* A SpritePrecedence is stored in a SPRT chunk. */
  269.  
  270. typedef UWORD SpritePrecedence;
  271.  
  272.     /* ======================= Viewport Mode =========================== */
  273.     /* A Commodore Amiga ViewPort->Modes is stored in a CAMG chunk. The
  274.          chunk's content is declared as a LONG. */
  275.  
  276. typedef struct {
  277.     ULONG    ViewModes;
  278.     } CamgChunk;
  279.  
  280.     /* ======================== CRNG =============================== */
  281.  
  282. #define maxCycles    8
  283. #define RNG_NORATE    36            /* Dpaint uses this rate to mean non-active */
  284.  
  285. typedef struct {
  286.     WORD    pad1;        /* future exp - store 0 here */
  287.     WORD    rate;        /* 60/sec=16384, 30/sec=8192, 1/sec=16384/60=273 */
  288.     WORD    active; /* lo bit 0=no cycle, 1=yes; next bit 1=rvs */
  289.     UBYTE    low;        /* range lower */
  290.     UBYTE    high;        /* range upper */
  291.     } CrngChunk;
  292.  
  293.  
  294.     /* ======================== CCRT =============================== */
  295.  
  296. typedef struct {
  297.     WORD    direction;        /* 0=don't cycle, 1=forward, -1=backwards */
  298.     UBYTE    start;            /* range lower */
  299.     UBYTE    end;                /* range upper */
  300.     LONG    seconds;            /* seconds between cycling */
  301.     LONG    microseconds;    /* msecs between cycling */
  302.     WORD    pad;                /* future exp - store 0 here */
  303.     } CcrtChunk;
  304.  
  305.  
  306.     /* =========================== ANHD ============================== */
  307.  
  308.     /* operation modes */
  309. #define DirectSet        0
  310. #define XOR                1
  311. #define LongDelta        2
  312. #define ShortDelta        3
  313. #define ShortLong        4
  314. #define ByteVertical    5
  315. #define Juggler         74
  316.  
  317.     /* Bits values */
  318. #define ShortData        0
  319. #define LongData            1
  320. #define Set                0
  321. #define Xor                2
  322. #define SeparateInfo    0
  323. #define OneInfoList        4
  324. #define NotRLC            0
  325. #define RLC                8
  326. #define Horizontal        0
  327. #define Vertical            16
  328. #define ShortInfo        0
  329. #define LongInfo            32
  330.  
  331. typedef struct {
  332.     UBYTE operation;
  333.     UBYTE mask;
  334.     UWORD w,h;
  335.     WORD    x,y;
  336.     ULONG    abstime;
  337.     ULONG reltime;
  338.     UBYTE interleave;
  339.     UBYTE AnhdPad0;
  340.     ULONG Bits;
  341.     UBYTE AnhdPad[16];
  342.     } AnhdChunk;
  343.  
  344.     /* ===================== ILBMFrame STRUCTURE ===================== */
  345.  
  346. typedef struct ILBMFrame {
  347.    UBYTE iFlags;
  348.    UBYTE iUserFlags;
  349.    BitMapHeader iBMHD;
  350.     ULONG    iViewModes;
  351.    Color4 iColorTable[maxColorReg];
  352.    UBYTE    iNumColors;
  353.    UBYTE iCycleCnt;
  354.    CrngChunk iCRNG[maxCycles];
  355.     struct Window *iWindow;
  356.     struct Screen *iScreen;
  357.     struct BitMap *iBMAP;
  358.     ULONG    iBMSize;
  359.    };
  360.  
  361.     /* definitions for iFlags field */
  362. #define BMHDFLAG    1    /* if a BMHD chunk found in the file */
  363. #define CAMGFLAG 2    /* if a CAMG chunk found */
  364. #define ANHDFLAG 4    /* if an ANHD chunk found. This is for the use of your
  365.                             custom CHUNKhandler or PROPhandler. */
  366.  
  367.     /* definitions for iUserFlags. These must be initialized by you. */
  368. #define MOUSEFLAG    1        /* no visible mouse pointer */
  369. #define SCREENFLAG    2        /* hides screen title bar */
  370. #define COLORFLAG    4    /* for "Don't use loaded colorMap. Use present map."*/
  371.  
  372. #define ANIMFLAG        0x80        /* if an ANIM file */
  373.  
  374.  
  375.     /* ================== ILBMPropFrame STRUCTURE =================== */
  376.     /* Defines for the ILBMPropFrame, because you'll reference from the
  377.         ILBMFrame field when using GetPROPStruct, SearchPROP, CopyILBMProp. */
  378. #define iNext        -10
  379. #define iID        -6
  380. #define iPFSize -2
  381.  
  382.     /* The ILBMPropFrame structure actually looks like this: */
  383. typedef struct {
  384.    struct ILBMPropFrame *NextPropFrame;
  385.    LONG ifID;
  386.    UWORD    PropFrameSize;
  387.     struct ILBMFrame PropFrame;  /* The address of this field is returned
  388.                                             by the lib PROP routines so that you can
  389.                                             treat it just like an ordinary ILBMFrame */
  390.    } ILBMPropFrame;
  391.  
  392.  
  393.     /* =================== PROPList STRUCTURE =================== */
  394.  
  395. typedef struct {
  396.    struct ILBMPropFrame *FirstPropFrame;
  397.    UWORD    NumPropFrames;
  398.    } PROPList;
  399.  
  400.  
  401.     /* =================== Vectors STRUCTURE ==================== */
  402. /* When using mid-level load routines, you must allocate and initialize a
  403.     vector structure. This structure holds the addresses of whatever routines
  404.     you would like the lib to execute while parsing an IFF file. If the
  405.     vector address is 0, then the default lib routine is used. */
  406.  
  407. typedef IFFP ClientProc();
  408.  
  409. typedef struct _Vectors {
  410.  ClientProc *PROPhandler;
  411.     /*    address of routine to handle nonILBM 'PROP's or an ILBM
  412.         PROP chunk that is "unknown" to the lib (i.e. ANHD,DEST,
  413.         GRAB,SPRT,DLTA). If NULL, skips nonILBM PROPs. */
  414.  ClientProc *FORMhandler;
  415.     /* If not NULL, replaces the lib's default 'FORM' handler. */
  416.  ClientProc *CHUNKhandler;
  417.     /* Called by lib's default 'FORM' handler when it encounters
  418.         "unknown" chunks inside an ILBM (see PROPhandler). If NULL,
  419.         unknown chunks are skipped. If you don't use the lib's
  420.         default 'FORM' handler, then this field is free to use. */
  421.  ClientProc *NonILBMhandler;
  422.     /* Called by lib's default 'FORM' handler when it encounters
  423.         a FORM other than ILBM (i.e. 8SVX, etc). If NULL,
  424.         nonILBM FORMs are skipped. If you don't use the lib's
  425.         default 'FORM' handler, then this field is free to use. */
  426.    } Vectors;
  427.  
  428.  
  429.     /* ================== Lib Reader Routines ================= */
  430.  
  431. #ifdef    FDwAT
  432.  
  433. extern IFFP OpenRIFF(BPTR, _GroupContext *, ULONG);
  434. extern IFFP OpenRGroup(_GroupContext *, _GroupContext *);
  435. extern IFFP CloseRGroup(_GroupContext *);
  436. extern ID    GetChunkHdr(_GroupContext *);
  437. extern IFFP IFFReadBytes(LONG, _GroupContext *, BYTE *);
  438. extern ID    GetFChunkHdr(_GroupContext *);
  439. extern ID    GetF1ChunkHdr(_GroupContext *);
  440. extern ID    GetPChunkHdr(_GroupContext *);
  441. extern IFFP SkipFwd(_GroupContext *, LONG);
  442. extern IFFP FileLength(BPTR);
  443. extern void DecodeVKPlane(ULONG, WORD *, BYTE *, BYTE *);
  444. extern void MakeYTable(ULONG, ULONG, WORD *);
  445. extern void DecompDLTA((BYTE *)dlta, struct BitMap *);
  446. extern void DecompBODY(BYTE *, BitMapHeader *, struct BitMap *);
  447. extern void SetupBitmap(UWORD *, struct BitMap *, BitMapHeader *);
  448.  
  449. extern ULONG GetPROPStruct(ULONG, ID, PROPList *);
  450. extern ULONG SearchPROP(ID, PROPList *);
  451. extern void  FreePROPStruct(PROPList *);
  452. extern void  CopyILBMPropF(ILBMFrame *, ILBMFrame *);
  453.  
  454. extern IFFP    HandleCAMG(_GroupContext *, ILBMFrame *);
  455. extern IFFP    HandleCCRT(_GroupContext *, ILBMFrame *);
  456. extern IFFP    HandleCRNG(_GroupContext *, ILBMFrame *);
  457. extern IFFP    GetCMAP(_GroupContext *, WORD *,   UBYTE *);
  458. extern IFFP    GetBODY(struct BitMap *,
  459.                             BYTE *, _GroupContext *, BitMapHeader *);
  460.  
  461. /* GetBODY can handle a file with up to 16 planes plus a mask.*/
  462. #define MaxSrcPlanes 16+1
  463.  
  464. /* This macro computes the worst case packed size of a "row" of bytes. */
  465. #define MaxPackedSize(rowSize)  ( (rowSize) + ( ((rowSize)+127) >> 7 ) )
  466.  
  467. extern BOOL UnPackRow(ULONG, ULONG, BYTE *, BYTE *);
  468.  
  469.  
  470. extern IFFP LoadILBM(BPTR, _Vectors *, ILBMFrame *);
  471. extern IFFP LoadIFF(BPTR, _Vectors *, ULONG);
  472. extern IFFP LoadIFFToWindow(BPTR, ILBMFrame *);
  473.  
  474. /* Note: Just call IFFReadBytes to read a BMHD, GRAB, DEST, SPRT, or CAMG
  475.     chunk. As below. */
  476. #define GetBMHD(context, bmHdr)  \
  477.     IFFReadBytes(sizeof(BitMapHeader), context, (BYTE *)bmHdr)
  478. #define GetGRAB(context, point2D)  \
  479.     IFFReadBytes(sizeof(Point2D) ,context, (BYTE *)point2D)
  480. #define GetDEST(context, destMerge)  \
  481.     IFFReadBytes(sizeof(DestMerge) ,context, (BYTE *)destMerge)
  482. #define GetSPRT(context, spritePrec)  \
  483.     IFFReadBytes(sizeof(SpritePrecedence) ,context, (BYTE *)spritePrec)
  484. #define GetCAMG(context, camg)  \
  485.     IFFReadBytes(sizeof(CamgChunk) ,context, (BYTE *)camg)
  486. #define GetCRNG(context, crng)  \
  487.     IFFReadBytes(sizeof(CrngChunk) ,context, (BYTE *)crng)
  488. #define GetCCRT(context, ccrt)  \
  489.     IFFReadBytes(sizeof(CcrtChunk) ,context, (BYTE *)ccrt)
  490. #define GetANHD(context, anhd)  \
  491.     IFFReadBytes(sizeof(AnhdChunk) ,context, (BYTE *)anhd)
  492.  
  493.  
  494. extern BOOL ScaleImage(struct Rectangle *, struct Rectangle *, struct BitMap *,  struct RastPort *);
  495.  
  496.     /* ================= Low Level IFF Writer ======================== */
  497.  
  498. extern IFFP OpenWIFF(LONG, BPTR, GroupContext *);
  499. extern IFFP StartWGroup(ID, LONG, ID, GroupContext *, GroupContext *);
  500. extern IFFP EndWGroup(GroupContext *);
  501. extern IFFP OpenWGroup(GroupContext *, GroupContext *);
  502. extern IFFP CloseWGroup(GroupContext *);
  503. extern IFFP PutCk(ID, LONG, GroupContext *, BYTE *);
  504. extern IFFP PutCkHdr(ID, LONG, GroupContext *);
  505. extern IFFP IFFWriteBytes(LONG, GroupContext *, BYTE *);
  506. extern IFFP PutCkEnd(GroupContext *);
  507. extern ULONG PackRow(ULONG, BYTE *, BYTE *);
  508. extern IFFP InitBMHdr(ULONG, ULONG, ULONG, ULONG, ULONG, BitMapHeader *,
  509.                             struct BitMap *);
  510.  
  511. extern IFFP PutCMAP(UBYTE, GroupContext *, WORD);
  512. extern IFFP PutBODY(BYTE *, GroupContext *, BitMapHeader *, struct BitMap *);
  513.  
  514.  
  515. extern IFFP SaveILBM(ULONG, ULONG, BPTR, BYTE *, UWORD *,
  516.                             struct BitMap *, Point2D *, ClientProc *);
  517. extern IFFP SaveANIM(ULONG, ULONG, BPTR, BYTE *, UWORD *,
  518.                             struct BitMap *, Point2D *, ClientProc *, ANHDchunk *);
  519. extern IFFP SaveWindowToIFF(BPTR, struct Window *);
  520.  
  521. /* Note: Just call PutCk to write a BMHD, GRAB, DEST, SPRT, or CAMG
  522.     chunk. As below. */
  523. #define PutBMHD(context, bmHdr)  \
  524.     PutCk(ID_BMHD, sizeof(BitMapHeader), context, (BYTE *)bmHdr)
  525. #define PutGRAB(context, point2D)  \
  526.     PutCk(ID_GRAB, sizeof(Point2D), context, (BYTE *)point2D)
  527. #define PutDEST(context, destMerge)  \
  528.     PutCk(ID_DEST, sizeof(DestMerge), context, (BYTE *)destMerge)
  529. #define PutSPRT(context, spritePrec)  \
  530.     PutCk(ID_SPRT, sizeof(SpritePrecedence), context, (BYTE *)spritePrec)
  531. #define PutANHD(context, AnhdChunk)  \
  532.     PutCk(ID_ANHD, sizeof(AnhdChunk), context, (BYTE *)AnhdChunk)
  533. #define PutCAMG(context, CamgChunk)  \
  534.     PutCk(ID_CAMG, sizeof(CamgChunk), context, (BYTE *)CamgChunk)
  535. #define PutCRNG(context, CrngChunk)  \
  536.     PutCk(ID_CRNG, sizeof(CrngChunk), context, (BYTE *)CrngChunk)
  537. #define PutCCRT(context, CcrtChunk)  \
  538.     PutCk(ID_CCRT, sizeof(CcrtChunk), context, (BYTE *)CcrtChunk)
  539.  
  540.  
  541. extern APTR GetIFFPMsg(IFFP);
  542. extern void BlankPointer(struct Window *);
  543.  
  544. #else
  545.  
  546. extern IFFP OpenRIFF();
  547. extern IFFP OpenRGroup();
  548. extern IFFP CloseRGroup();
  549. extern ID    GetChunkHdr();
  550. extern IFFP IFFReadBytes();
  551. extern ID    GetFChunkHdr();
  552. extern ID    GetF1ChunkHdr();
  553. extern ID    GetPChunkHdr();
  554. extern IFFP SkipFwd();
  555. extern IFFP FileLength();
  556. extern void DecodeVKPlane();
  557. extern void MakeYTable();
  558. extern void DecompDLTA();
  559. extern void DecompBODY();
  560. extern void SetupBitmap();
  561.  
  562. extern ULONG GetPROPStruct();
  563. extern ULONG SearchPROP();
  564. extern void  FreePROPStruct();
  565. extern void  CopyILBMPropF();
  566.  
  567. extern IFFP    HandleCAMG();
  568. extern IFFP    HandleCCRT();
  569. extern IFFP    HandleCRNG();
  570. extern IFFP    GetCMAP();
  571. extern IFFP    GetBODY();
  572.  
  573. /* GetBODY can handle a file with up to 16 planes plus a mask.*/
  574. #define MaxSrcPlanes 16+1
  575.  
  576. /* This macro computes the worst case packed size of a "row" of bytes. */
  577. #define MaxPackedSize(rowSize)  ( (rowSize) + ( ((rowSize)+127) >> 7 ) )
  578.  
  579. extern BOOL UnPackRow();
  580.  
  581.  
  582. extern IFFP LoadILBM();
  583. extern IFFP LoadIFF();
  584. extern IFFP LoadIFFToWindow();
  585.  
  586. /* Note: Just call IFFReadBytes to read a BMHD, GRAB, DEST, SPRT, or CAMG
  587.     chunk. As below. */
  588. #define GetBMHD(context, bmHdr)  \
  589.     IFFReadBytes(sizeof(BitMapHeader), context, (BYTE *)bmHdr)
  590. #define GetGRAB(context, point2D)  \
  591.     IFFReadBytes(sizeof(Point2D) ,context, (BYTE *)point2D)
  592. #define GetDEST(context, destMerge)  \
  593.     IFFReadBytes(sizeof(DestMerge) ,context, (BYTE *)destMerge)
  594. #define GetSPRT(context, spritePrec)  \
  595.     IFFReadBytes(sizeof(SpritePrecedence) ,context, (BYTE *)spritePrec)
  596. #define GetCAMG(context, camg)  \
  597.     IFFReadBytes(sizeof(CamgChunk) ,context, (BYTE *)camg)
  598. #define GetCRNG(context, crng)  \
  599.     IFFReadBytes(sizeof(CrngChunk) ,context, (BYTE *)crng)
  600. #define GetCCRT(context, ccrt)  \
  601.     IFFReadBytes(sizeof(CcrtChunk) ,context, (BYTE *)ccrt)
  602. #define GetANHD(context, anhd)  \
  603.     IFFReadBytes(sizeof(AnhdChunk) ,context, (BYTE *)anhd)
  604.  
  605.  
  606.     /* ================= Low Level IFF Writer ======================== */
  607.  
  608. extern IFFP OpenWIFF();
  609. extern IFFP StartWGroup();
  610. extern IFFP EndWGroup();
  611. extern IFFP OpenWGroup();
  612. extern IFFP CloseWGroup();
  613. extern IFFP PutCk();
  614. extern IFFP PutCkHdr();
  615. extern IFFP IFFWriteBytes();
  616. extern IFFP PutCkEnd();
  617. extern ULONG PackRow();
  618. extern IFFP InitBMHdr();
  619.  
  620. extern IFFP PutCMAP();
  621. extern IFFP PutBODY();
  622.  
  623.  
  624. extern IFFP SaveILBM();
  625. extern IFFP SaveANIM();
  626. extern IFFP SaveWindowToIFF();
  627.  
  628. extern BOOL ScaleImage();
  629.  
  630. /* Note: Just call PutCk to write a BMHD, GRAB, DEST, SPRT, or CAMG
  631.     chunk. As below. */
  632. #define PutBMHD(context, bmHdr)  \
  633.     PutCk(ID_BMHD, sizeof(BitMapHeader), context, (BYTE *)bmHdr)
  634. #define PutGRAB(context, point2D)  \
  635.     PutCk(ID_GRAB, sizeof(Point2D), context, (BYTE *)point2D)
  636. #define PutDEST(context, destMerge)  \
  637.     PutCk(ID_DEST, sizeof(DestMerge), context, (BYTE *)destMerge)
  638. #define PutSPRT(context, spritePrec)  \
  639.     PutCk(ID_SPRT, sizeof(SpritePrecedence), context, (BYTE *)spritePrec)
  640. #define PutANHD(context, AnhdChunk)  \
  641.     PutCk(ID_ANHD, sizeof(AnhdChunk), context, (BYTE *)AnhdChunk)
  642. #define PutCAMG(context, CamgChunk)  \
  643.     PutCk(ID_CAMG, sizeof(CamgChunk), context, (BYTE *)CamgChunk)
  644. #define PutCRNG(context, CrngChunk)  \
  645.     PutCk(ID_CRNG, sizeof(CrngChunk), context, (BYTE *)CrngChunk)
  646. #define PutCCRT(context, CcrtChunk)  \
  647.     PutCk(ID_CCRT, sizeof(CcrtChunk), context, (BYTE *)CcrtChunk)
  648.  
  649.  
  650. extern APTR GetIFFPMsg();
  651. extern void BlankPointer();
  652.  
  653. #endif
  654.  
  655. typedef UBYTE *UBytePtr;
  656.  
  657. #endif ILBMLIB_H
  658.  
  659.  
  660.