2 *************************************************************************
\r
4 * PCX_INT.H - PCX_LIB Library Internal Definitions Include File
\r
8 * History: 91/02/14 - Created
\r
9 * 91/04/01 - Release 1.00A
\r
10 * 91/04/07 - Release 1.00B
\r
12 * Compiler: Microsoft C V6.0
\r
14 * Author: Ian Ashdown, P.Eng.
\r
16 * 620 Ballantree Road
\r
17 * West Vancouver, B.C.
\r
19 * Tel. (604) 922-6148
\r
20 * Fax. (604) 987-7621
\r
22 * Copyright: Public Domain
\r
24 *************************************************************************
\r
29 #define _PCX_INT_H 1
\r
32 #include "PCX_EXT.H" /* Get external PCX definitions, etc. */
\r
35 #define PCX_HERC 0xff /* Hercules 720 x 348 monochrome mode */
\r
37 #define PCX_COMP_FLAG 0xc0 /* Compressed data flag mask */
\r
38 #define PCX_COMP_MASK 0x3f /* Data repeat count mask */
\r
40 #define PCX_PAL_MASK 0x03 /* Palette interpretation mask */
\r
41 #define PCX_EPAL_FLAG 0x0c /* Extended palette flag */
\r
43 #define PCX_PAL_SIZE 16 /* File header palette size */
\r
44 #define PCX_EPAL_SIZE 256 /* Extended palette size */
\r
46 #define PCX_MAXLINESZ 640 /* Maximum PCX line buffer size */
\r
48 /* Color graphics adapter color palette macros */
\r
50 #define PCX_CGA_BKGND(x) (x[0].red >> 4) /* Background color */
\r
51 #define PCX_CGA_BURST(x) (x[1].red & 0x80) /* Color burst */
\r
52 #define PCX_CGA_SELECT(x) (x[1].red & 0x40) /* Palette selector */
\r
53 #define PCX_CGA_INTENSITY(x) (x[1].red & 0x20) /* Intensity */
\r
55 typedef unsigned char BYTE; /* 8-bit data type */
\r
56 typedef unsigned int WORD; /* 16-bit data type */
\r
58 /* STRUCTURE DECLARATIONS */
\r
60 typedef struct pcx_pal /* PCX palette array element */
\r
62 BYTE red; /* Red intensity */
\r
63 BYTE green; /* Green intensity */
\r
64 BYTE blue; /* Blue intensity */
\r
68 typedef struct pcx_hdr /* PCX file header (Version 5) */
\r
70 BYTE pcx_id; /* Always 0x0a for PCX files */
\r
71 BYTE version; /* Version number */
\r
72 BYTE encoding; /* 1 = PCX run length encoding */
\r
73 BYTE bppixel; /* Number of bits/pixel per color plane */
\r
74 WORD xul; /* X-position of upper left corner */
\r
75 WORD yul; /* Y-position of upper left corner */
\r
76 WORD xlr; /* X-position of lower right corner */
\r
77 WORD ylr; /* Y-position of lower right corner */
\r
78 WORD horz_res; /* Horizontal resolution */
\r
79 WORD vert_res; /* Vertical resolution */
\r
80 PCX_PAL palette[PCX_PAL_SIZE]; /* Hardware R-G-B palette */
\r
81 BYTE reserved; /* Unused in Version 5 */
\r
82 BYTE nplanes; /* Number of color planes */
\r
83 WORD bppscan; /* Number of bytes per plane scan line */
\r
84 WORD palette_type; /* Palette interpretation */
\r
85 WORD scrn_width; /* Horizontal screen size in pixels */
\r
86 WORD scrn_height; /* Vertical screen size in pixels */
\r
87 BYTE filler[54]; /* Padding to fill out 128-byte header */
\r
91 /* 1. The "version" member may be one of the following: */
\r
93 /* 0 - PC Paintbrush Version 2.5 */
\r
94 /* 2 - PC Paintbrush Version 2.8 (with palette information) */
\r
95 /* 3 - PC Paintbrush Version 2.8 (w/o palette information) */
\r
96 /* 4 - PC Paintbrush for Windows (PC Paintbrush Plus for */
\r
97 /* Windows and Windows 3.0 Paintbrush use Version 5) */
\r
98 /* 5 - PC Paintbrush 3.0 and greater (including PC Paintbrush */
\r
99 /* Plus and Publisher's Paintbrush) */
\r
101 /* 2. ZSoft Corporation has reserved the right to change the */
\r
102 /* encoding method in future versions for better image */
\r
103 /* compression performance. The "encoding" member value may */
\r
104 /* change accordingly. */
\r
106 /* 3. The value of the "bppixel" member depends on the type of */
\r
107 /* video display adapter and its video mode. Typical values */
\r
108 /* are 1, 2, 4 and 8. */
\r
110 /* 4. The "xul", "yul", "xlr" and "ylr" members are zero-based and */
\r
111 /* and inclusive values indicating the position of the image on */
\r
112 /* the screen. The display functions can ignore this */
\r
113 /* information if desired. */
\r
115 /* 5. The "horz_res" and "vert_res" members refer to the "dots per */
\r
116 /* inch" resolution of the scanning device used to create the */
\r
117 /* image. For images created on video display adapters, these */
\r
118 /* values typically refer to the horizontal and vertical */
\r
119 /* resolutions in pixels (e.g. - 640 x 350 for an EGA display). */
\r
121 /* The display function ignore these members, as some programs */
\r
122 /* programs do not bother to initialize them when creating PCX */
\r
125 /* 6. The "palette" member is typically left uninitialized if an */
\r
126 /* extended 256-color palette is appended to the PCX image */
\r
129 /* 7. The "reserved" member used to contain the MS-DOS video mode */
\r
130 /* that the PCX image was intended to be displayed under. This */
\r
131 /* member is ignored in Version 5. ZSoft recommends that it be */
\r
134 /* 8. The value of the "nplanes" member depends on the type of */
\r
135 /* video display adapter and its video mode. Typical values */
\r
136 /* are 1, 2, 3 and 4. */
\r
138 /* 9. The value of the "bppscan" member should be an even number */
\r
139 /* (for compatibility with some existing commercial programs.) */
\r
140 /* It indicates the number of bytes required to buffer a */
\r
141 /* decoded scan line for one color plane. */
\r
143 /* 10. The "palette_type" member indicates whether the palette */
\r
144 /* represents a color or grayscale palette. It is a bit-mapped */
\r
145 /* variable (only the lowest two bits are significant; the */
\r
146 /* others are ignored) with two possible values: */
\r
148 /* 0x01 - color or black & white */
\r
149 /* 0x02 - grayscale */
\r
151 /* If "grayscale" is indicated, the file color palette must be */
\r
152 /* set to shades of gray. The file decoding functions can then */
\r
153 /* either use this palette or assume a default grayscale */
\r
154 /* palette if necessary. */
\r
156 /* PC Paintbrush IV and IV Plus ignore this member. */
\r
158 /* 11. The "scrn_width" and "scrn_height" members were added for */
\r
159 /* PC Paintbrush IV Version 1.02 and IV Plus Version 1.0. They */
\r
160 /* may not be initialized in some older Version 5 PCX files, or */
\r
161 /* the "scrn_width" member may be initialized with the screen */
\r
162 /* height and the "scrn_height" member uninitialized. ZSoft */
\r
163 /* recommends that this information be ignored. */
\r
165 /* 12. ZSoft recommends that the "filler" bytes be set to zero. */
\r
169 typedef struct pcx_workblk /* PCX image file workblock */
\r
173 FILE *fp; /* PCX image file pointer */
\r
174 PCX_HDR header; /* PCX image file header */
\r
175 PCX_PAL *palettep; /* Color palette pointer */
\r
176 BOOL epal_flag; /* Extended color palette flag */
\r
178 /* Image manipulation variables */
\r
180 int num_bytes; /* Number of bytes to display */
\r
181 int mask; /* Unseen pixels mask */
\r
182 unsigned long page_offset; /* Display page address offset */
\r
184 /* Image manipulation function pointer */
\r
186 void (*pcx_funcp)(struct pcx_workblk *, unsigned char _far *, int);
\r
190 /* FUNCTIONS PROTOTYPES */
\r
192 extern BOOL pcx_close(PCX_WORKBLK *);
\r
194 extern PCX_WORKBLK *pcx_open(char *, BOOL);
\r