📄 pcx.htm
字号:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>zsoft pcx file format technical reference manual introduction 2 image file </title>
<meta name="generator" content="microsoft frontpage 3.0">
</head>
<body background="../jpg/di1.JPG">
<p align="center"><font size="6" color="#0000ff">pcx file format reference</font></p>
<div align="center"><center>
<table border="0" width="88%">
<tr>
<td width="100%"><font size="5"><a href="#introduction">introduction</a></font> <br>
<a
href="#image file (.pcx) format">image file (.pcx) format</a> <br>
<a
href="#zsoft .pcx file header format">zsoft .pcx file header format</a><br>
<a
href="#decoding .pcx files">decoding .pcx files</a> <br>
<font size="5"><a href="#palette information description">palette information description </a></font><br>
<a
href="#ega/vga 16 color palette information">ega/vga 16 color palette information </a><br>
<a
href="#vga 256 color palette information">vga 256 color palette information</a> <br>
<a
href="#24-bit .pcx files">24-bit .pcx files 8</a> <br>
<a
href="#cga color palette information">cga color palette information</a> <br>
<a
href="#cga color map">cga color map</a> <br>
<a href="#pc paintbrush bitmap character format"><font size="5">pc paintbrush bitmap
character format</font></a><br>
<a
href="#sample "c" routines">sample "c" routines</a> <br>
<font size="5"><a href="#frieze technical information">frieze technical information</a></font>
<br>
<a
href="#general frieze information">general frieze information</a> <br>
<a
href="#7.00 and later frieze">7.00 and later frieze</a> <br>
<a
href="#frieze function calls">frieze function calls</a> <br>
<a href="#frieze error codes">frieze
error codes</a> <br>
<br>
<a name="introduction">introduction</a><br>
<br>
this booklet was designed to aid developers and users in understanding<br>
the technical aspects of the .pcx file format and the use of frieze.<br>
any comments, questions or suggestions about this booklet should be<br>
sent to:<br>
<br>
zsoft corporation<br>
technical services<br>
attn: code librarian<br>
450 franklin rd. suite 100<br>
marietta, ga 30067<br>
<br>
<br>
<br>
technical reference manual information compiled by:<br>
dean ansley<br>
<br>
<br>
revision 5<br>
<br>
to down load additional information and the source for a complete<br>
turbo pascal program to show .pcx files on a cga/ega/vga graphics<br>
display, call our bbs at (404)427-1045. you may use a 9600 baud <br>
modem or a 2400 baud standard modem. your modem should be set for<br>
8 data bits, 1 stop bit, and no parity.<br>
<br>
<a name="image file (.pcx) format">image file (.pcx) format</a><br>
<br>
if you have technical questions on the format, please do not call<br>
technical support. zsoft provides this document as a courtesy to<br>
its users and developers. it is not the function of technical support<br>
to provide programming assistance. if something is not clear, leave a<br>
message on our bbs, compuserve, or write us a letter at the above address.<br>
<br>
the information in this section will be useful if you want to write a<br>
program to read or write pcx files (images). if you want to write a<br>
special case program for one particular image format you should be able<br>
to produce something that runs twice as fast as "load from..." in<br>
pc paintbrush. <br>
<br>
image files used by pc paintbrush product family and frieze (those with a<br>
.pcx extension) begin with a 128 byte header. usually you can ignore this<br>
header, since your images will probably all have the same resolution. if<br>
you want to process different resolutions or colors, you will need to<br>
interpret the header correctly. the remainder of the image file consists<br>
of encoded graphic data. the encoding method is a simple byte oriented<br>
run-length technique. we reserve the right to change this method to<br>
improve space efficiency. when more than one color plane is stored in<br>
the file, each line of the image is stored by color plane (generally ordered<br>
red, green, blue, intensity), as shown below.<br>
<br>
scan line 0: rrr... (plane 0)<br>
ggg... (plane 1)<br>
bbb... (plane 2)<br>
iii... (plane 3)<br>
scan line 1: rrr...<br>
ggg...<br>
bbb...<br>
iii... (etc.)<br>
<br>
the encoding method is:<br>
for each byte, x, read from the file<br>
if the top two bits of x are 1's then<br>
count = 6 lowest bits of x<br>
data = next byte following x<br>
else<br>
count = 1<br>
data = x<br>
<br>
since the overhead this technique requires is, on average, 25% of<br>
the non-repeating data and is at least offset whenever bytes are repeated,<br>
the file storage savings are usually considerable.<br>
<br>
<a name="zsoft .pcx file header format">zsoft .pcx file header format</a><br>
<br>
byte item size description/comments <br>
0 manufacturer 1 constant flag, 10 = zsoft .pcx <br>
1 version 1 version information <br>
0 = version 2.5 of pc paintbrush <br>
2 = version 2.8 w/palette information <br>
3 = version 2.8 w/o palette information <br>
4 = pc paintbrush for windows(plus for<br>
windows uses ver 5) <br>
5 = version 3.0 and > of pc paintbrush<br>
and pc paintbrush +, includes<br>
publisher's paintbrush . includes<br>
24-bit .pcx files <br>
2 encoding 1 1 = .pcx run length encoding <br>
3 bitsperpixel 1 number of bits to represent a pixel<br>
(per plane) - 1, 2, 4, or 8 <br>
4 window 8 image dimensions: xmin,ymin,xmax,ymax <br>
12 hdpi 2 horizontal resolution of image in dpi* <br>
14 vdpi 2 vertical resolution of image in dpi* <br>
16 colormap 48 color palette setting, see text <br>
64 reserved 1 should be set to 0. <br>
65 nplanes 1 number of color planes <br>
66 bytesperline 2 number of bytes to allocate for a scanline<br>
plane. must be an even number. do not<br>
calculate from xmax-xmin. <br>
68 paletteinfo 2 how to interpret palette- 1 = color/bw,<br>
2 = grayscale (ignored in pb iv/ iv +) <br>
70 hscreensize 2 horizontal screen size in pixels. new field<br>
found only in pb iv/iv plus <br>
72 vscreensize 2 vertical screen size in pixels. new field<br>
found only in pb iv/iv plus <br>
74 filler 54 blank to fill out 128 byte header. set all<br>
bytes to 0 <br>
<br>
notes:<br>
<br>
all sizes are measured in bytes. <br>
<br>
all variables of size 2 are integers. <br>
<br>
*hdpi and vdpi represent the horizontal and vertical resolutions which the<br>
image was created (either printer or scanner); i.e. an image which was<br>
scanned might have 300 and 300 in each of these fields.<br>
<br>
<a name="decoding .pcx files">decoding .pcx files</a><br>
<br>
first, find the pixel dimensions of the image by calculating<br>
[xsize = xmax - xmin + 1] and [ysize = ymax - ymin + 1]. then calculate<br>
how many bytes are required to hold one complete uncompressed scan line:<br>
<br>
totalbytes = nplanes * bytesperline<br>
<br>
note that since there are always an even number of bytes per scan line,<br>
there will probably be unused data at the end of each scan line. totalbytes<br>
shows how much storage must be available to decode each scan line, including<br>
any blank area on the right side of the image. you can now begin decoding<br>
the first scan line - read the first byte of data from the file. if the<br>
top two bits are set, the remaining six bits in the byte show how many times<br>
to duplicate the next byte in the file. if the top two bits are not set,<br>
the first byte is the data itself, with a count of one.<br>
<br>
continue decoding the rest of the line. keep a running subtotal of how<br>
many bytes are moved and duplicated into the output buffer. when the<br>
subtotal equals totalbytes, the scan line is complete. there should always<br>
be a decoding break at the end of each scan line. but there will not be a<br>
decoding break at the end of each plane within each scan line. when the<br>
scan line is completed, there may be extra blank data at the end of each<br>
plane within the scan line. use the xsize and ysize values to find where<br>
the valid image data is. if the data is multi-plane, bytesperline shows<br>
where each plane ends within the scan line.<br>
<br>
continue decoding the remainder of the scan lines (do not just read to<br>
end-of-file). there may be additional data after the end of the image<br>
(palette, etc.)<br>
<br>
<a name="palette information description">palette information description</a><br>
<br>
<a name="ega/vga 16 color palette information">ega/vga 16 color palette information</a><br>
<br>
in standard rgb format (ibm ega, ibm vga) the data is stored as 16 triples.<br>
each triple is a 3 byte quantity of red, green, blue values. the values can<br>
range from 0-255, so some interpretation may be necessary. on an ibm ega,<br>
for example, there are 4 possible levels of rgb for each color. since<br>
256/4 = 64, the following is a list of the settings and levels:<br>
<br>
setting level<br>
0-63 0<br>
64-127 1<br>
128-192 2<br>
193-254 3<br>
<br>
<a name="vga 256 color palette information">vga 256 color palette information</a><br>
<br>
zsoft has recently added the capability to store palettes containing more<br>
than 16 colors in the .pcx image file. the 256 color palette is formatted<br>
and treated the same as the 16 color palette, except that it is substantially<br>
longer. the palette (number of colors x 3 bytes in length) is appended to<br>
the end of the .pcx file, and is preceded by a 12 decimal. since the vga<br>
device expects a palette value to be 0-63 instead of 0-255, you need to<br>
divide the values read in the palette by 4.<br>
<br>
to access a 256 color palette:<br>
<br>
first, check the version number in the header; if it contains a 5 there is<br>
a palette.<br>
<br>
second, read to the end of the file and count back 769 bytes. the value<br>
you find should be a 12 decimal, showing the presence of a 256 color palette.<br>
<br>
<a name="24-bit .pcx files">24-bit .pcx files</a><br>
<br>
24 bit images are stored as version 5 or above as 8 bit, 3 plane images.<br>
<br>
24 bit images do not contain a palette.<br>
<br>
bit planes are ordered as lines of red, green, blue in that order.<br>
<br>
<a name="cga color palette information">cga color palette information</a><br>
<br>
note: this is no longer supported for pc paintbrush iv/iv plus.<br>
<br>
for a standard ibm cga board, the palette settings are a bit more complex.<br>
only the first byte of the triple is used. the first triple has a valid<br>
first byte which represents the background../jpg/di1.JPG. to find the background,<br>
take the (unsigned) byte value and divide by 16. this will give a result<br>
between 0-15, hence the background../jpg/di1.JPG. the second triple has a valid<br>
first byte, which represents the foreground palette. pc paintbrush supports<br>
8 possible cga palettes, so when the foreground setting is encoded between<br>
0 and 255, there are 8 ranges of numbers and the divisor is 32.<br>
<br>
<a name="cga color map">cga color map</a><br>
<br>
header byte #16 <br>
<br>
background../jpg/di1.JPGr is determined in the upper four bits.<br>
<br>
header byte #19<br>
<br>
only upper 3 bits are used, lower 5 bits are ignored. the first three bits<br>
that are used are ordered c, p, i. these bits are interpreted as follows:<br>
<br>
c: color burst enable - 0 = color; 1 = monochrome<br>
<br>
p: palette - 0 = yellow; 1 = white<br>
<br>
i: intensity - 0 = dim; 1 = bright<br>
<br>
<a name="pc paintbrush bitmap character format">pc paintbrush bitmap character format</a><br>
<br>
note: this format is for pc paintbrush (up to vers 3.7) and pc paintbrush<br>
plus (up to vers 1.65)<br>
<br>
the bitmap character fonts are stored in a particularly simple format. the<br>
format of these characters is as follows:<br>
<br>
<br>
header<br>
<br>
font width byte 0xa0 + character width (in pixels)<br>
font height byte character height (in pixels)<br>
<br>
character width table<br>
<br>
char widths (256 bytes) each char's width + 1 pixel of kerning<br>
<br>
character images<br>
<br>
(remainder of the file) starts at char 0 (null)<br>
<br>
the characters are stored in ascii order and as many as 256 may be provided.<br>
each character is left justified in the character block, all characters take<br>
up the same number of bytes.<br>
<br>
bytes are organized as n strings, where each string is one scan line of the<br>
character.<br>
<br>
for example, each character in a 5x7 font requires 7 bytes. a 9x14 font<br>
uses 28 bytes per character (stored two bytes per scan line in 14 sets of<br>
2 byte packets). custom fonts may be any size up to the current maximum of<br>
10k bytes allowed for a font file. there is a maximum of 4 bytes per scan<br>
line.<br>
<br>
<a name="sample "c" routines">sample "c" routines</a><br>
<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -