]> Creatis software - clitk.git/blob - utilities/CxImage/ximapcx.h
6e18f1561b1fe844f5b9e34bd1595847f2113884
[clitk.git] / utilities / CxImage / ximapcx.h
1 /*\r
2  * File:        ximapcx.h\r
3  * Purpose:     PCX Image Class Loader and Writer\r
4  */\r
5 /* ==========================================================\r
6  * CxImagePCX (c) 05/Jan/2002 Davide Pizzolato - www.xdp.it\r
7  * For conditions of distribution and use, see copyright notice in ximage.h\r
8  *\r
9  * Parts of the code come from Paintlib: Copyright (c) 1996-1998 Ulrich von Zadow\r
10  * ==========================================================\r
11  */\r
12 #if !defined(__ximaPCX_h)\r
13 #define __ximaPCX_h\r
14 \r
15 #include "ximage.h"\r
16 \r
17 #if CXIMAGE_SUPPORT_PCX\r
18 \r
19 class CxImagePCX: public CxImage\r
20 {\r
21 // PCX Image File\r
22 #pragma pack(1)\r
23 typedef struct tagPCXHEADER\r
24 {\r
25   char Manufacturer;    // always 0X0A\r
26   char Version;                 // version number\r
27   char Encoding;                // always 1\r
28   char BitsPerPixel;    // color bits\r
29   WORD Xmin, Ymin;              // image origin\r
30   WORD Xmax, Ymax;              // image dimensions\r
31   WORD Hres, Vres;              // resolution values\r
32   BYTE ColorMap[16][3]; // color palette\r
33   char Reserved;\r
34   char ColorPlanes;             // color planes\r
35   WORD BytesPerLine;    // line buffer size\r
36   WORD PaletteType;             // grey or color palette\r
37   char Filter[58];\r
38 } PCXHEADER;\r
39 #pragma pack()\r
40 \r
41 public:\r
42         CxImagePCX(): CxImage(CXIMAGE_FORMAT_PCX) {}\r
43 \r
44 //      bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_PCX);}\r
45 //      bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_PCX);}\r
46         bool Decode(CxFile * hFile);\r
47         bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); }\r
48 \r
49 #if CXIMAGE_SUPPORT_ENCODE\r
50         bool Encode(CxFile * hFile);\r
51         bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); }\r
52 #endif // CXIMAGE_SUPPORT_ENCODE\r
53 protected:\r
54         bool PCX_PlanesToPixels(BYTE * pixels, BYTE * bitplanes, short bytesperline, short planes, short bitsperpixel);\r
55         bool PCX_UnpackPixels(BYTE * pixels, BYTE * bitplanes, short bytesperline, short planes, short bitsperpixel);\r
56         void PCX_PackPixels(const long p,BYTE &c, BYTE &n, CxFile &f);\r
57         void PCX_PackPlanes(BYTE* buff, const long size, CxFile &f);\r
58         void PCX_PixelsToPlanes(BYTE* raw, long width, BYTE* buf, long plane);\r
59         void PCX_toh(PCXHEADER* p);\r
60 };\r
61 \r
62 #endif\r
63 \r
64 #endif\r