home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- //
- // File: PCX.HPP
- // Path: ...\REHACK\graphics
- // Version: 2.0
- // Author: Dave Boynton
- // CIS Id: 71043,317
- // Created On: January 1992
- // Modified On: 7/25/93
- // Description: header file for PcxFile & PcxFile256 classes
- // Tabs: 4
- //
- //---------------------------------------------------------------------------
- // extracted/modified from pcxlib 2.0 (c) 1992,1993 David Boynton
- // All rights reserved.
- //-----------------------------------------------------------------------//
- #ifndef _PCX_HPP
- #define _PCX_HPP
-
- #include <stdio.h>
- #include "..\general\types.hpp"
-
- #define ALIGN_DWORD(x) (((x)+3)/4 * 4)
-
- struct PCXRGB {
- unsigned char r, g, b;
- };
-
- const word PCXMAGICID=0x0a;
-
- typedef struct { // begining of all .pcx files
- char magicId;
- char version; // 5 means 256 color w/palette at end
- char encoding; // 1 means RLE, readLine's description
- char bitsPixel; // must be 8 for Version 5
- word xMin, yMin;
- word xMax, yMax;
- word hRes, vRes;
- struct PCXRGB palette[16]; /* used only on 16 color pcx's */
- char reserved;
- char planes; // must be 1 for Version 5
- word bytesLine; // double-word aligned
- word paletteInfo;
- char filler[58]; // there's other stuff in here, but it's
- // used for anything useful.
- } PCXH;
-
- typedef struct PCXRGB Palette[256];
-
- class PcxFile {
- public:
- PCXH *header;
- FILE *fp;
- long filestart; // for use with resource files
- byte *lineBuffer;
- bool validFlag;
- word hPixels, vPixels;
- word bytesPerLine;
-
- ~PcxFile(); // closes file, deletes lineBuffer;
- bool isValid(void) { return validFlag; }
-
- PcxFile(char *filename); // input file
- PcxFile(FILE *fp); // for resource files, sets filestart
- PcxFile(char *filename, word xSize, word ySize); //output file
-
- bool readHeader(void);
- bool writeHeader(void);
- };
-
- class PcxFile256 : public PcxFile {
- public:
- struct PCXRGB * palette;
-
- PcxFile256(char *filename); // input file
- PcxFile256(FILE *fp); // for resource files, sets filestart
- PcxFile256(char *filename, word xSize, word ySize); //output file
- ~PcxFile256();
-
- bool readPalette(void);
- bool writePalette(void);
-
- void shiftPaletteDown(void);
- void shiftPaletteUp(void);
-
- bool skipLine(void);
- bool seekLine(word line);
- bool readLine(byte * destBuffer, word x0, word x1);
- bool writeLine(byte * srcBuffer, word x0, word x1, byte fill=0);
- bool readLine(void) { return readLine(lineBuffer, 0, hPixels-1); }
- bool writeLine(void) { return writeLine(lineBuffer, 0, hPixels-1); }
-
- };
-
- #endif // _PCX_HPP
-
-
-
-