/*========================================================================= * * PCX.H - 1 December 1998, Dave Humphrey * *=======================================================================*/ #ifndef __PCX_H #define __PCX_H /* Required Includes */ #include "genutil.h" /* To ensure proper size of structures */ #ifdef _WIN32 #pragma pack(push, save_pack) #pragma pack(1) #endif /*========================================================================= * * rgb_palette_t Definition * * Common used palette type for images. * *=======================================================================*/ typedef struct { union { unsigned char R, r; }; union { unsigned char G, g; }; union { unsigned char B, b; }; } rgb_palette_t; /*========================================================================= * End of rgb_palette_t Definition *=======================================================================*/ /*========================================================================= * * Class CPCXHeader Definition * * Defines the header class for a PCX file. * *=======================================================================*/ class CPCXHeader { public: char Manufacturer; char Version; char Encoding; char BitsPerPixel; short X; short Y; short Width; short Height; short HorzResolution; short VertResolution; char EGAPalette[48]; char Reserved; char NumColorPlanes; short BytesPerLine; short PaletteType; char Padding[58]; /* Padding for future use */ /* Class Constructor */ CPCXHeader (void) { Destroy(); } /* Class Destructor */ void Destroy (void); /* Loads the header from the given file */ boolean Read (FILE* pFileHandle); /* Write the header to the given file */ boolean Write (FILE* pFileHandle); }; /*========================================================================= * End of Class CPCXHeader Definition *=======================================================================*/ /*========================================================================= * * Class CPCXImage Definition * * The main class for handling a PCX type image. * *=======================================================================*/ class CPCXImage { public: CPCXHeader Header; /* Header info */ rgb_palette_t Palette[256]; /* Palette data */ byte* pData; /* Raw image data (uncompressed) */ /* Class Constructor */ CPCXImage (void) { pData = NULL; } /* Class Destructors */ ~CPCXImage (void) { Destroy(); } void Destroy (void); /* Exports a LBM image to a PCX file */ boolean ExportLBM (const char* pFilename, const int Width, const int Height, byte* pImage, const byte* pPalette); boolean ExportLBM (const char* pFilename, const int Width, const int Height, byte* pImage); /* Attempt to load the specified PCX image */ boolean Load (const char* pFilename); /* Attempt to save the PCX image to the give file */ boolean Save (const char* pFilename); /* Translates palette entries from a 256 color RGB palette */ void SetVGAPalette (const byte* pVGAPal); }; /*========================================================================= * End of Class CPCXImage Definition *=======================================================================*/ #ifdef _WIN32 #pragma pack(pop, save_pack) #endif #endif /*========================================================================= * End of File PCX.H *=======================================================================*/