home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / disks / disk458.lzh / GIFMachine / Sources / GIFMachine.h < prev    next >
C/C++ Source or Header  |  1991-02-15  |  3KB  |  106 lines

  1. /* Copyright 1990 by Christopher A. Wichura.
  2.    See file GIFMachine.doc for full description of rights.
  3. */
  4.  
  5. #include <exec/types.h>
  6. #include <exec/lists.h>
  7. #include <exec/nodes.h>
  8. #include <proto/dos.h>
  9. #include <proto/exec.h>
  10. #include <string.h>
  11. #include <stdlib.h>
  12.  
  13. /* we only use this for testing purposes */
  14. void kprintf(UBYTE *, ...);
  15.  
  16. /* some structures to make parsing the gif files a bit easier */
  17. struct GIFdescriptor {
  18.     UWORD gd_Width;
  19.     UWORD gd_Height;
  20.     UBYTE gd_ColInfo;
  21.     UBYTE gd_BackGround;
  22.     UBYTE gd_PixelAspect;    /* Aspect Ratio = (Pixel Aspect + 15) / 64 */
  23. };
  24.  
  25. struct ImageDesc {
  26.     UWORD id_Left;
  27.     UWORD id_Top;
  28.     UWORD id_Width;
  29.     UWORD id_Height;
  30.     UBYTE id_Info;
  31. };
  32.  
  33. struct RGB {
  34.     UBYTE rgb_Red;
  35.     UBYTE rgb_Green;
  36.     UBYTE rgb_Blue;
  37. };
  38.  
  39. #define GIF_IMAGE      0x2C
  40. #define GIF_EXTENSION  0x21
  41. #define GIF_TERMINATOR 0x3B
  42.  
  43. #define GIF_COMMENT_EXT 0xFE
  44.  
  45. #define MAXCOLOURS 4096
  46.  
  47. /* these next macros are used to get the r, g, and b values of a given
  48.    index */
  49. #define GetRed(a)    (UBYTE)(a >> 8)
  50. #define GetGreen(a)    (UBYTE)((a >> 4) & 0xF)
  51. #define GetBlue(a)    (UBYTE)(a & 0xF)
  52.  
  53. /* whenever we want to abort we will return this as our error code */
  54. #define ABORTEXITVAL 1
  55.  
  56. /* this struct is used to hold the linked list of comments found in the GIF
  57.    file so that each can be written as a seperate ANNO chunk. */
  58. struct CommentNode {
  59.     struct MinNode cn_Node;
  60.     char *cn_Comment;
  61.     ULONG cn_CommentLength;
  62. };
  63.  
  64. /* function prototypes we use */
  65. extern int __regargs main(char *cmdptr, int cmdlen, struct WBStartup *WBMsg);
  66. extern void    WarnMustUseCLI(void);
  67. extern void    DoPattern(char *);
  68. extern void    Convert(char *);
  69. extern BOOL    IsDir(char *);
  70. extern void    FlipWord(UWORD *);
  71. extern BOOL    DoImage(BPTR);
  72. extern BOOL    DoExtension(BPTR);
  73. extern BOOL    WriteIFF(char *, BOOL);
  74. extern void    PutValue(UWORD, UWORD, UWORD);
  75. extern UWORD    GetValue(UWORD, UWORD);
  76. extern int    ReadCode(BPTR);
  77. extern void    AddPixel(UBYTE);
  78. extern void    StripBorder(void);
  79. extern BOOL    BorderCheck(UWORD, UWORD);
  80. extern void    DoXComp(void);
  81. extern void    GIFtoSHAM(void);
  82. extern void    InitDiff(void);
  83. extern ULONG    RGBdiff(UBYTE, UBYTE, UBYTE, UBYTE, UBYTE, UBYTE);
  84. extern void    OutDump(int);
  85. extern void    OutRun(int, int);
  86. extern void    InitMemory(void);
  87. extern char *    MyAlloc(ULONG);
  88. extern void    MyFree(char *);
  89. extern void    FreeAll(UWORD);
  90. extern void    MyExit(ULONG);
  91. extern void    DoXFlip(void);
  92. extern void    DoYFlip(void);
  93. extern void    ReduceTo12(void);
  94. extern void    DitherTo12(void);
  95. extern UWORD    AddColour(struct RGB *);
  96. extern void __stdargs MyPrintf(char *, ...);
  97. extern void __stdargs MySPrintf(char *, char *, ...);
  98.  
  99. /* modules that want to use the Get/PutValue macros should include this
  100.    next macro to externally reference the picture storage array */
  101. #define EXTERNBITPLANE extern struct RGB **BitPlane
  102.  
  103. /* for use once colour palette has been reduced to 12 bits */
  104. #define GetValue(a, b) *((UWORD *)&BitPlane[b][a])
  105. #define PutValue(a, b, c) *((UWORD *)&BitPlane[b][a]) = c
  106.