home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 612b.lha / PicPak_v1.3c / pic_pak.h < prev    next >
C/C++ Source or Header  |  1992-02-01  |  7KB  |  170 lines

  1. /***************************************************************************
  2.  * pic_pak.h   - "PicPak" - IFF ILBM picture manipulation functions        *
  3.  *                (c) 1990 Videoworks Computer Applications                *
  4.  *                All rights reserved.                                     *
  5.  *                                                                         *
  6.  *                Written by Paul T. Miller                                *
  7.  *                                                                         *
  8.  * DISCLAIMER:                                                             *
  9.  * Feel free to use these routines or derivatives in your own code, but    *
  10.  * please leave credit in your documentation. This code is NOT public      *
  11.  * domain, and I am only allowing use of it because I'm a nice guy and I   *
  12.  * want to show people how to effectively use their code. If you make any  *
  13.  * modifications or enhancements to this code, please let me know.         *
  14.  *                                                                         *
  15.  * Send comments/suggestions to:                                           *
  16.  * Paul Miller                                                             *
  17.  * The MBT, Coconut Telegraph, The TARDIS                                  *
  18.  *                                                                         *
  19.  * Program Name:  N/A                                                      *
  20.  * Version:       1                                                        *
  21.  * Revision:      3                                                        *
  22.  *-------------------------------------------------------------------------*
  23.  * File: (pic_pak.h) IFF package definitions and function prototypes       *
  24.  *-------------------------------------------------------------------------*
  25.  * Modification History                                                    *
  26.  * Date     Author   Comment                                               *
  27.  * -------- ------   -------                                               *
  28.  * 10-02-90    PTM   Created. Structures, constants.
  29.  * 10-03-90    PTM   iff.library hooks
  30.  * 10-16-90    PTM   use custom iff code - remove the library
  31.  * 11-28-90    PTM   Special picture types - package name change
  32.  * 11-30-90    PTM   Add Pic extension pointer + SHAMData struct
  33.  * 12-02-90    PTM   Frame structure
  34.  ***************************************************************************/
  35.  
  36. #ifndef PIC_PAK_H
  37. #define PIC_PAK_H
  38.  
  39. #ifndef NULL
  40. #include <stdio.h>
  41. #endif
  42.  
  43. /* some useful constants */
  44. #define LORES_WIDTH        320
  45. #define LORES_HEIGHT       200
  46. #define HIRES_WIDTH        640
  47. #define INTERLACE_HEIGHT   400
  48. #define HAM_DEPTH          6
  49. #define EHB_DEPTH          6
  50.  
  51. #define MAXCOLORS          32
  52. #define MAXCRANGES         6
  53.  
  54. typedef struct {
  55.    WORD pad1;         /* Odd length? Nope. */
  56.    WORD rate;         /* Speed! */
  57.    WORD active;       /* What shall we do with a drunken... */
  58.    UBYTE low,high;    /* That's where we start and stop. */
  59. } CRange;
  60.  
  61. /* Pic structure:
  62.       - contains Pic-specific information such as size, type of memory
  63.         it's stored in, viewmode and imagery data
  64. */
  65. struct Pic {
  66.    WORD              Width;      /* width of Pic (in pixels) */
  67.    WORD              Height;     /* height of Pic (in pixels) */
  68.    UBYTE             Depth;      /* depth of Pic (in planes) */
  69.    UBYTE             Memtype;    /* type of memory image is stored in */
  70.    UWORD             Colors;     /* total number of colors */
  71.    ULONG             ViewModes;  /* ViewMode bits */
  72.    struct BitMap     BitMap;     /* the image's BitMap */
  73.    UWORD             Colormap[MAXCOLORS]; /* the image's colormap */
  74.    CRange            CRanges[MAXCRANGES]; /* cycle-range blocks */
  75.    UWORD             Cycles;     /* how many cycle ranges? */
  76.    UBYTE             Type;       /* picture type */
  77.    UBYTE             pad;
  78.    APTR             *PicExt;     /* pointer to Pic extension data */
  79. };
  80. #define PIC_SIZE (sizeof(struct Pic))
  81.  
  82. /* Frame structure:
  83.       - contains just positional and image information, for use with displays
  84.         of known size, depth, and colors. Frames are always in CHIP ram. */
  85. struct Frame {
  86.    WORD              X, Y;       /* upper-left corner */
  87.    WORD              Width;      /* width of frame */
  88.    WORD              Height;     /* height of frame */
  89.    struct BitMap     BitMap;     /* the frame's BitMap */
  90. };
  91. #define FRAME_SIZE   (sizeof(struct Frame))
  92.  
  93. /* picture types */
  94. #define PICTYPE_NORMAL  0
  95. #define PICTYPE_HAM     1
  96. #define PICTYPE_EHB     2
  97. #define PICTYPE_DHAM    3
  98. #define PICTYPE_SHAM    4
  99. #define PICTYPE_DHIRES  5
  100. #define PICTYPE_HAME    6
  101. #define PICTYPE_DCTV    7
  102. #define PICTYPE_24BIT   9
  103. #define PICTYPE_FRAME   20          /* just positional info please */
  104.  
  105. /* Picture Extension chunks */
  106. #define SHAM_PALETTES   200
  107. #define SHAM_COLORS     16
  108.  
  109. struct SHAMData {
  110.    UWORD ColorTable[SHAM_PALETTES][16];  /* 200 palettes/16 colors each */
  111. };
  112. #define SHAMDATA_SIZE   sizeof(struct SHAMData)
  113.  
  114. #define DHIRES_PALETTES 480
  115. #define DHIRES_COLORS   16
  116.  
  117. /* Pic MemTypes */
  118. /* When used in calling AllocatePic(), specifies type of RAM to allocate
  119.    for the imagery. Then used internally to notify whether an image is
  120.    actually in FAST RAM or not, so it can be downloaded to CHIP for display
  121. */
  122. #define MEMTYPE_CHIP 0x00  /* must have CHIP RAM */
  123. #define MEMTYPE_FAST 0x01  /* must have FAST RAM */
  124. #define MEMTYPE_ANY  0x02  /* doesn't matter what type it is */
  125. #define MEMTYPE_NONE 0x10  /* no memory allocated */
  126. #define MEMTYPE_DL   0x80  /* currently downloaded, erase when done */
  127.  
  128. /* pic_pak function prototypes */
  129. struct Pic *AllocatePic(UWORD width, UWORD height, UBYTE depth, UBYTE flags);
  130. void FreePic(struct Pic *pic);
  131. struct Frame *AllocateFrame(UWORD width, UWORD height, UBYTE flags);
  132. void FreeFrame(struct Frame *frame);
  133. struct Pic *LoadPic(STRPTR name, UBYTE flags);
  134. struct Pic *LoadPic2BitMap(STRPTR name, struct BitMap *bitmap);
  135. struct Frame *LoadFrame(STRPTR name);
  136. struct Pic *LoadImage(STRPTR name, struct BitMap *bitmap, UBYTE type, UBYTE flags);
  137. GetPicAttrs(STRPTR name, WORD *w, WORD *h, WORD *d, ULONG *viewmodes);
  138. Pic2BitMap(struct Pic *pic, struct BitMap *bitmap);
  139. BOOL LoadRaster(FILE *file, ULONG chunksize, PLANEPTR *planes,
  140.                 struct BitMapHeader *header);
  141.  
  142. void mem_decompress(UBYTE *mem, PLANEPTR *, LONG, LONG, UBYTE);
  143. void SetPicReadBufSize(ULONG);
  144. UWORD LoadCMAP(FILE *, LONG, UWORD *);
  145. void LoadCycleRange(FILE *, CRange *, LONG);
  146. void SetImageType(struct Pic *);
  147.  
  148. /* color-cycling */
  149. InitCycler(void);
  150. void FreeCycler(void);
  151. __saveds void cycle(void);
  152. void StartCycling(struct ViewPort *, struct Pic *);
  153. void StopCycling(void);
  154. void ToggleCycling(void);
  155. IsCycling(void);
  156.  
  157. /* ViewPort color-set/fading */
  158. void SetViewPortPicColors(struct ViewPort *, struct Pic *);
  159. void ClearViewPortColors(struct ViewPort *, UWORD);
  160. void FadeViewPortIn(struct ViewPort *, UWORD *, UWORD);
  161. void FadeViewPortOut(struct ViewPort *, UWORD);
  162. void SetFadeSpeed(UWORD);
  163.  
  164. /* Special image handling */
  165. InitSHAM(struct ViewPort *, struct Pic *);
  166. InitDHIRES(struct ViewPort *, struct Pic *);
  167. void FreeSHAM(struct ViewPort *);
  168.  
  169. #endif /* PIC_PAK_H */
  170.