Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

pliff85.h

00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: pliff85.h,v 1.2 2004/04/16 20:14:41 uzadow Exp $
00005 |
00006 |      Defines structures and constants present in Electronic Arts IFF-85
00007 |      files, in particular those in ILBM and PBM files.
00008 |
00009 |       REFERENCES :
00010 |           Jerry Morrison, Electronic Arts; "EA IFF 85" Standard for
00011 |           Interchange Format Files; January 14, 1985
00012 |           Available from http://www.wotsit.org as iff.zip
00013 |
00014 |           Jerry Morrison, Electronic Arts; "ILBM" IFF Interleaved Bitmap;
00015 |           January 17, 1986
00016 |           Available from http://www.wotsit.org as ilbm.zip
00017 | 
00018 |           Carolyn Scheppner - Commodore Amiga Technical Support;
00019 |           "Intro to Amiga IFF ILBM Files and Amiga Viewmodes";
00020 |           USENET posting to comp.graphics, comp.sys.amiga;
00021 |           August 25th, 1988
00022 | 
00023 |      Rupert Welch (rafw@mindless.com) - December 2003
00024 |
00025 |      Copyright (c) 2003-2004 Ulrich von Zadow
00026 |
00027 \--------------------------------------------------------------------
00028 */
00029 
00030 #if !defined(INCL_PLIFF85)
00031 #define      INCL_PLIFF85
00032 
00033 #include "pldebug.h"
00034 #include "plpaintlibdefs.h"
00035 
00036 // Standard IFF-85 constants and types.
00037 namespace PLIFF85
00038 {
00039   // Standard IFF types based on their paintlib equivalents (where available).
00040   // This allows the stuff below to follow the documentation more closely.
00041   typedef PLBYTE          UBYTE;  //< 8-bit unsigned
00042   typedef signed short    WORD;   //< 16-bit signed
00043   typedef PLWORD          UWORD;  //< 16-bit unsigned
00044   typedef PLLONG          LONG;   //< 32-bit signed
00045 
00046   typedef LONG ID;        //< 4 chars in ' ' through '~'.
00047 
00048   // Chunks are the building blocks in the IFF structure.
00049   struct Chunk
00050   {
00051     ID      ckID;       //< Chunk ID
00052     LONG    ckSize;     //< size of the chunk data following.
00053     // This is followed by ckSize UBYTEs.
00054   };
00055 
00056   // Converts a 4-character string to a IFF chunk ID format.
00057   inline ID MakeID(const char IDStr[4], bool validate = true)
00058   {
00059     if (validate)
00060     {
00061       PLASSERT(IDStr[0] >= ' ');
00062       PLASSERT(IDStr[0] <= '~');
00063       PLASSERT(IDStr[1] >= ' ');
00064       PLASSERT(IDStr[1] <= '~');
00065       PLASSERT(IDStr[2] >= ' ');
00066       PLASSERT(IDStr[2] <= '~');
00067       PLASSERT(IDStr[3] >= ' ');
00068       PLASSERT(IDStr[3] <= '~');
00069     }
00070     return ((UBYTE(IDStr[0]) << 24) |
00071             (UBYTE(IDStr[1]) << 16) |
00072             (UBYTE(IDStr[2]) << 8) |
00073             (UBYTE(IDStr[3])));
00074   }
00075 
00076   const ID ID_FORM    = MakeID("FORM");   //< All valid IFF files should start with this.
00077   const ID ID_ILBM    = MakeID("ILBM");   //< A ILBM image.
00078   const ID ID_PBM     = MakeID("PBM ");   //< A PBM image.
00079   const ID ID_BMHD    = MakeID("BMHD");   //< Bitmap header.
00080   const ID ID_CMAP    = MakeID("CMAP");   //< A colormap, or palette.
00081   const ID ID_CAMG    = MakeID("CAMG");   //< Commodore AMiGa viewmodes.
00082   const ID ID_BODY    = MakeID("BODY");   //< The body of the image.
00083 
00084   // BMHD types.
00085 
00086   typedef UBYTE Masking;  //< Choice of masking technique.
00087 
00088   // Designates an opaque rectangular image.
00089   const Masking mskNone                   = 0;
00090 
00091   // \brief This means that a mask plane is interleaved with the bitplanes
00092   // in the BODY chunk.
00093   const Masking mskHasMask                = 1;
00094 
00095   // \brief Indicates that pixels in the source planes matching
00096   // transparentColor are to be considered "transparent".
00097   const Masking mskHasTransparentColor    = 2;
00098 
00099   // Indicates the reader may construct a mask by lassoing the image.
00100   const Masking mskLasso                  = 3;
00101 
00102   // \brief Choice of compression algorithm applied to the rows of all
00103   // source and mask planes.
00104   // \note Do not compress across rows!
00105   typedef UBYTE Compression;
00106 
00107   const Compression cmpNone       = 0;    //< No compression.
00108 
00109   // This is the byte run encoding described in Appendix C of the ILBM definition.
00110   const Compression cmpByteRun1   = 1;
00111 
00112   // The required property "BMHD" holds a BitMapHeader as defined here.
00113   // It describes the dimensions and encoding of the image, including
00114   // data necessary to understand the BODY chunk to follow.
00115   struct BitMapHeader
00116   {
00117     UWORD       w;                      //< raster width in pixels.
00118     UWORD       h;                      //< raster height in pixels.
00119     WORD        x;                      //< pixel position for this image.
00120     WORD        y;                      //< pixel position for this image.
00121     UBYTE       nPlanes;                //< # source bitplanes
00122     Masking     masking;                //< masking type.
00123     Compression compression;            //< Compression type.
00124     UBYTE       pad1;                   //< unused; for consistency, put 0 here.
00125     UWORD       transparentColor;       //< transparent "color number" (sort of).
00126     UBYTE       xAspect;                //< pixel aspect, a ratio width : height.
00127     UBYTE       yAspect;                //< pixel aspect, a ratio width : height.
00128     WORD        pageWidth;              //< source "page" size in pixels.
00129     WORD        pageHeight;             //< source "page" size in pixels.
00130   };
00131 
00132   // The optional (but encouraged) property "CMAP" stores color map data
00133   // as triplets of red, green, and blue intensity values. The n color
00134   // map entries ("color registers") are stored in the order 0 through
00135   // n-1, totaling 3n bytes. Thus n is the ckSize/3. Normally, n would
00136   // equal 2 raised to the power of nPlanes.
00137   //
00138   // A CMAP chunk contains a ColorMap array as defined below. (These
00139   // typedefs assume a C compiler that implements packed arrays of
00140   // 3-byte elements.)
00141   struct ColorRegister
00142   {
00143     UBYTE red;                  //< red intensity 0..255.
00144     UBYTE green;                //< green intensity 0..255.
00145     UBYTE blue;                 //< blue intensity 0..255.
00146   };
00147 
00148 //  typedef ColorRegister ColorMap[n];  /* size = 3n bytes */
00149 
00150   // Commodore Amiga viewport mode.
00151   typedef LONG Viewmode;
00152 
00153   // Viewmode masks.
00154 
00155   // Hold-and-Modify.  The bits in the two last planes describe an R G or B
00156   // modification to the color of the previous pixel on the line to create
00157   // the color of the current pixel.
00158   const Viewmode viewHAM    = 0x00000800;
00159 
00160 } // namespace PLIFF85
00161 
00162 #endif // !defined(INCL_PLIFF85)
00163 
00164 /*
00165 /--------------------------------------------------------------------
00166 |
00167 |      $Log: pliff85.h,v $
00168 |      Revision 1.2  2004/04/16 20:14:41  uzadow
00169 |      Changes to make cdoc work.
00170 |
00171 |      Revision 1.1  2004/03/13 19:40:23  uzadow
00172 |      Added Rupert Welchs iff decoder.
00173 |
00174 |
00175 |
00176 \--------------------------------------------------------------------
00177 */

Generated on Sun Jun 6 13:42:22 2004 for paintlib by doxygen 1.3.2