home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Freeware / Utilitare / VisualBoyAdvance-1.7.2 / win32 / include / cximage / ximapcx.h < prev    next >
C/C++ Source or Header  |  2004-02-29  |  3KB  |  81 lines

  1. /*
  2.  * File:    ximapcx.h
  3.  * Purpose:    PCX Image Class Loader and Writer
  4.  */
  5. /* === C R E D I T S  &  D I S C L A I M E R S ==============
  6.  * CxImagePCX (c) 05/Jan/2002 Davide Pizzolato - www.xdp.it
  7.  * Permission is given by the author to freely redistribute and include
  8.  * this code in any program as long as this credit is given where due.
  9.  *
  10.  * CxImage version 5.99a 08/Feb/2004
  11.  * See the file history.htm for the complete bugfix and news report.
  12.  *
  13.  * Parts of the code come from Paintlib
  14.  * Copyright (c) 1996-1998 Ulrich von Zadow
  15.  *
  16.  * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
  17.  * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
  18.  * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
  19.  * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
  20.  * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
  21.  * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
  22.  * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
  23.  * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  24.  * THIS DISCLAIMER.
  25.  *
  26.  * Use at your own risk!
  27.  * ==========================================================
  28.  */
  29. #if !defined(__ximaPCX_h)
  30. #define __ximaPCX_h
  31.  
  32. #include "ximage.h"
  33.  
  34. #if CXIMAGE_SUPPORT_PCX
  35.  
  36. class CxImagePCX: public CxImage
  37. {
  38. // PCX Image File
  39. #pragma pack(1)
  40. typedef struct tagPCXHEADER
  41. {
  42.   char Manufacturer;    // always 0X0A
  43.   char Version;            // version number
  44.   char Encoding;        // always 1
  45.   char BitsPerPixel;    // color bits
  46.   WORD Xmin, Ymin;        // image origin
  47.   WORD Xmax, Ymax;        // image dimensions
  48.   WORD Hres, Vres;        // resolution values
  49.   BYTE ColorMap[16][3];    // color palette
  50.   char Reserved;
  51.   char ColorPlanes;        // color planes
  52.   WORD BytesPerLine;    // line buffer size
  53.   WORD PaletteType;        // grey or color palette
  54.   char Filter[58];
  55. } PCXHEADER;
  56. #pragma pack()
  57.  
  58. public:
  59.     CxImagePCX(): CxImage(CXIMAGE_FORMAT_PCX) {}
  60.  
  61. //    bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_PCX);}
  62. //    bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_PCX);}
  63.     bool Decode(CxFile * hFile);
  64.     bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); }
  65.  
  66. #if CXIMAGE_SUPPORT_ENCODE
  67.     bool Encode(CxFile * hFile);
  68.     bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); }
  69. #endif // CXIMAGE_SUPPORT_ENCODE
  70. protected:
  71.     void PCX_PlanesToPixels(BYTE * pixels, BYTE * bitplanes, short bytesperline, short planes, short bitsperpixel);
  72.     void PCX_UnpackPixels(BYTE * pixels, BYTE * bitplanes, short bytesperline, short planes, short bitsperpixel);
  73.     void PCX_PackPixels(const long p,BYTE &c, BYTE &n, CxFile &f);
  74.     void PCX_PackPlanes(BYTE* buff, const long size, CxFile &f);
  75.     void PCX_PixelsToPlanes(BYTE* raw, long width, BYTE* buf, long plane);
  76. };
  77.  
  78. #endif
  79.  
  80. #endif
  81.