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