Imported Upstream version 4.6.0
[debian/atlc] / docs / html-docs / bmp.html
1 <html>
2
3 <head>
4 <TITLE>Bitmap Format.</TITLE>
5 <meta http-equiv="content-type" content="text/html; charset=gb_2312-80">
6 <meta name="generator" content="microsoft frontpage 3.0">
7 <meta name="subject" content="windows bitmap file format specifications">
8 <meta name="major version" content="1">
9 <meta name="minor version" content="0">
10 <meta name="template" content="c:\msoffice\templates\c3word60.dot">
11 </head>
12
13 <p align="center"><font face="book antiqua" size="6" color="#0000ff">bmp format</font></p>
14 <div align="center"><center>
15
16 <table border="0" width="88%">
17   <tr>
18     <td width="100%"><b><p align="justify"><font face="book antiqua" size="6">table of 
19     contents</font></p>
20     <font face="book antiqua" size="4"><p><a href="#_toc381201081">introduction</a> <br>
21     <a href="#_toc381201082">bitmap file format</a><br>
22     </font><font face="book antiqua" size="3"> 
23     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a
24     href="#_toc381201083">general</a> <br>
25     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a
26     href="#_toc381201084">bmp contents</a> <br>
27     </font><font face="book antiqua" size="4"><a href="#_toc381201085">field details </a><br>
28     </font><font face="book antiqua" size="3"> 
29     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a
30     href="#_toc381201086">height field </a><br>
31     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a
32     href="#_toc381201087">bits per pixel field</a> <br>
33     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a
34     href="#_toc381201088">compression field</a> <br>
35     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a
36     href="#_toc381201089">colors field</a> <br>
37     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a
38     href="#_toc381201090">important colors field</a> </font><u><font face="book antiqua"
39     size="4">
40     </font></u><font face="book antiqua" size="6"><a name="_toc381201081"><p>introduction</a>
41     </font></b><font face="book antiqua" size="3"><p align="justify">this document describes 
42     the microsoft windows and ibm os/2 picture bitmap files, called bitmaps or bmp files. most 
43     of the descriptions of the bmp file concentrate on the microsoft windows bmp structures 
44     like </font><font face="courier new" size="3">bmpinfoheader</font><font
45     face="book antiqua" size="3"> and </font><font face="courier new" size="3">bmpcoreinfo</font><font
46     face="book antiqua" size="3"> , but only a few describe the file contents on byte level. 
47     this information is therefor only intended to be used in applications where direct reading 
48     and writing of a bmp file is required.
49     </font><b><font face="ÝðÞ\85" lang="zh-cn" size="6"><p align="justify"></font><font
50     face="book antiqua" size="6"><a name="_toc381201082">bitmap file format</a></p>
51     </font></b><font face="book antiqua" size="3"><p align="justify">the following chapters 
52     contain the detailed information on the contents of the bmp file. first more general 
53     information will be given regarding the byte order and file alignment. the second chapter 
54     will concentrate on the byte-level contents of a bmp file. the third chapter will 
55     elaborate on this chapter and explain some of the concepts - like compression - and/or 
56     values in detail.</p>
57     </font><b><font face="ÝðÞ\85" lang="zh-cn" size="5"><p></font><font face="book antiqua"
58     size="5"><a name="_toc381201083">general</a>
59     </font></b><font face="book antiqua" size="3"><p align="justify">the bmp file has been 
60     created by microsoft and ibm and is therefor very strictly bound to the architecture of 
61     the main hardware platform that both companies support: the ibm compatible pc. this means 
62     that all values stored in the bmp file are in the intel format, sometimes also called the 
63     little endian format because of the byte order that an intel processor uses internally to 
64     store values.</p>
65     <p align="justify">the bmp files are the way, windows stores bit mapped images. the bmp 
66     image data is bit packed but every line must end on a dword boundary - if that</font><font
67     face="ÝðÞ\85" lang="zh-cn" size="3">Æs</font><font size="3"> </font><font
68     face="book antiqua" size="3">not the case, it must be padded with zeroes. bmp files are 
69     stored bottom-up, that means that the first scan line is the bottom line. </p>
70     <p align="justify">the bmp format has four incarnations, two under windows (new and old) 
71     and two under os/2, all are described here.</p>
72     </font><b><font face="ÝðÞ\85" lang="zh-cn" size="5"><p></font><font face="book antiqua"
73     size="5"><a name="_toc381201084">bmp contents</a>
74     </font></b><font face="book antiqua" size="3"><p align="justify">the following table 
75     contains a description of the contents of the bmp file. for every field, the file offset, 
76     the length and the contents will be given. for a more detailed discussion, see the 
77     following chapters.</p>
78     </font><table border="1" cellspacing="2" bordercolor="#000000" cellpadding="7" width="657">
79       <tr>
80         <td width="10%" valign="top"><font face="book antiqua" size="3" color="#808080"><b><p
81         align="justify">offset</b></font></td>
82         <td width="16%" valign="top"><font face="book antiqua" size="3" color="#808080"><b><p
83         align="justify">field</b></font></td>
84         <td width="14%" valign="top"><font face="book antiqua" size="3" color="#808080"><b><p
85         align="justify">size</b></font></td>
86         <td width="61%" valign="top"><font face="book antiqua" size="3" color="#808080"><b><p
87         align="justify">contents</b></font></td>
88       </tr>
89       <tr>
90         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">0000h</font></td>
91         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">identifier</font></td>
92         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">2 bytes</font></td>
93         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">the 
94         characters identifying the bitmap. the following entries are possible:</p>
95         </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify">æB</font><font
96         face="book antiqua" size="3">m</font><font size="3">í¯ </font><font face="book antiqua"
97         size="3">- windows 3.1x, 95, nt, </font><font size="3">í¡</font><font face="book antiqua"
98         size="3">
99         </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify">æB</font><font
100         face="book antiqua" size="3">a</font><font size="3">í¯ </font><font face="book antiqua"
101         size="3">- os/2 bitmap array
102         </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify">æC</font><font
103         face="book antiqua" size="3">i</font><font size="3">í¯ </font><font face="book antiqua"
104         size="3">- os/2 color icon
105         </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify">æC</font><font
106         face="book antiqua" size="3">p</font><font size="3">í¯ </font><font face="book antiqua"
107         size="3">- os/2 color pointer
108         </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify">æI</font><font
109         face="book antiqua" size="3">c</font><font size="3">í¯ </font><font face="book antiqua"
110         size="3">- os/2 icon
111         </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify">æP</font><font
112         face="book antiqua" size="3">t</font><font size="3">í¯ </font><font face="book antiqua"
113         size="3">- os/2 pointer</font></td>
114       </tr>
115       <tr>
116         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">0002h</font></td>
117         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">file 
118         size</font></td>
119         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 dword</font></td>
120         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">complete 
121         file size in bytes.</font></td>
122       </tr>
123       <tr>
124         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">0006h</font></td>
125         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">reserved</font></td>
126         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 dword</font></td>
127         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">reserved 
128         for later use.</font></td>
129       </tr>
130       <tr>
131         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">000ah</font></td>
132         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">bitmap 
133         data offset</font></td>
134         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 dword</font></td>
135         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">offset 
136         from beginning of file to the beginning of the bitmap data.</font></td>
137       </tr>
138       <tr>
139         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">000eh</font></td>
140         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">bitmap 
141         header size</font></td>
142         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 dword</font></td>
143         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">length 
144         of the bitmap info header used to describe the bitmap colors, compression, </font><font
145         size="3">í¡ </font><font face="book antiqua" size="3">the following sizes are possible:</p>
146         <p align="justify">28h - windows 3.1x, 95, nt, </font><font size="3">í¡</font><font
147         face="book antiqua" size="3"></p>
148         <p align="justify">0ch - os/2 1.x</p>
149         <p align="justify">f0h - os/2 2.x</font></td>
150       </tr>
151       <tr>
152         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">0012h</font></td>
153         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">width</font></td>
154         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 dword</font></td>
155         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">horizontal 
156         width of bitmap in pixels.</font></td>
157       </tr>
158       <tr>
159         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">0016h</font></td>
160         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">height</font></td>
161         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 dword</font></td>
162         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">vertical 
163         height of bitmap in pixels.</font></td>
164       </tr>
165       <tr>
166         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">001ah</font></td>
167         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">planes</font></td>
168         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 word</font></td>
169         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">number 
170         of planes in this bitmap.</font></td>
171       </tr>
172       <tr>
173         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">001ch</font></td>
174         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">bits 
175         per pixel</font></td>
176         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 word</font></td>
177         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">bits 
178         per pixel used to store palette entry information. this also identifies in an indirect way 
179         the number of possible colors. possible values are:</p>
180         <p align="justify">1 - monochrome bitmap</p>
181         <p align="justify">4 - 16 color bitmap</p>
182         <p align="justify">8 - 256 color bitmap</p>
183         <p align="justify">16 - 16bit (high color) bitmap</p>
184         <p align="justify">24 - 24bit (true color) bitmap</p>
185         <p align="justify">32 - 32bit (true color) bitmap</font></td>
186       </tr>
187       <tr>
188         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">001eh</font></td>
189         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">compression</font></td>
190         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 dword</font></td>
191         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">compression 
192         specifications. the following values are possible:</p>
193         <p align="justify">0 - none (also identified by bi_rgb)</p>
194         <p align="justify">1 - rle 8-bit / pixel (also identified by bi_rle4)</p>
195         <p align="justify">2 - rle 4-bit / pixel (also identified by bi_rle8)</p>
196         <p align="justify">3 - bitfields (also identified by bi_bitfields)</font></td>
197       </tr>
198       <tr>
199         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">0022h</font></td>
200         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">bitmap 
201         data size</font></td>
202         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 dword</font></td>
203         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">size of 
204         the bitmap data in bytes. this number must be rounded to the next 4 byte boundary.</font></td>
205       </tr>
206       <tr>
207         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">0026h</font></td>
208         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">hresolution</font></td>
209         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 dword</font></td>
210         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">horizontal 
211         resolution expressed in pixel per meter.</font></td>
212       </tr>
213       <tr>
214         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">002ah</font></td>
215         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">vresolution</font></td>
216         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 dword</font></td>
217         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">vertical 
218         resolution expressed in pixels per meter.</font></td>
219       </tr>
220       <tr>
221         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">002eh</font></td>
222         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">colors</font></td>
223         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 dword</font></td>
224         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">number 
225         of colors used by this bitmap. for a 8-bit / pixel bitmap this will be 100h or 256.</font></td>
226       </tr>
227       <tr>
228         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">0032h</font></td>
229         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">important 
230         colors</font></td>
231         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">1 dword</font></td>
232         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">number 
233         of important colors. this number will be equal to the number of colors when every color is 
234         important.</font></td>
235       </tr>
236       <tr>
237         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">0036h</font></td>
238         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">palette</font></td>
239         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">n * 4 
240         byte</font></td>
241         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">the 
242         palette specification. for every entry in the palette four bytes are used to describe the 
243         rgb values of the color in the following way:</p>
244         <p align="justify">1 byte for blue component</p>
245 <HR><H3>Transfer interrupted!</H3>
246 p>
247         <p align="justify">1 byte for red component</p>
248         <p align="justify">1 byte filler which is set to 0 (zero)</font></td>
249       </tr>
250       <tr>
251         <td width="10%" valign="top"><font face="book antiqua" size="3"><p align="justify">0436h</font></td>
252         <td width="16%" valign="top"><font face="book antiqua" size="3"><p align="justify">bitmap 
253         data</font></td>
254         <td width="14%" valign="top"><font face="book antiqua" size="3"><p align="justify">x bytes</font></td>
255         <td width="61%" valign="top"><font face="book antiqua" size="3"><p align="justify">depending 
256         on the compression specifications, this field contains all the bitmap data bytes which 
257         represent indices in the color palette.</font></td>
258       </tr>
259     </table>
260     <font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify">íí</p>
261     </font><font face="book antiqua" size="3"><i><b><p align="justify">note:</b> the following 
262     sizes were used in the specification above: </p>
263     </i></font><table border="1" cellspacing="2" bordercolor="#000000" cellpadding="7"
264     width="226">
265       <tr>
266         <td width="30%" valign="top"><font face="book antiqua" size="3" color="#808080"><b><p
267         align="justify">size</b></font></td>
268         <td width="32%" valign="top"><font face="book antiqua" size="3" color="#808080"><b><p
269         align="justify"># bytes</b></font></td>
270         <td width="37%" valign="top"><font face="book antiqua" size="3" color="#808080"><b><p
271         align="justify">sign</b></font></td>
272       </tr>
273       <tr>
274         <td width="30%" valign="top"><font face="book antiqua" size="3"><p align="justify">char</font></td>
275         <td width="32%" valign="top"><font face="book antiqua" size="3"><p align="justify">1</font></td>
276         <td width="37%" valign="top"><font face="book antiqua" size="3"><p align="justify">signed</font></td>
277       </tr>
278       <tr>
279         <td width="30%" valign="top"><font face="book antiqua" size="3"><p align="justify">word</font></td>
280         <td width="32%" valign="top"><font face="book antiqua" size="3"><p align="justify">2</font></td>
281         <td width="37%" valign="top"><font face="book antiqua" size="3"><p align="justify">unsigned</font></td>
282       </tr>
283       <tr>
284         <td width="30%" valign="top"><font face="book antiqua" size="3"><p align="justify">dword</font></td>
285         <td width="32%" valign="top"><font face="book antiqua" size="3"><p align="justify">4</font></td>
286         <td width="37%" valign="top"><font face="book antiqua" size="3"><p align="justify">unsigned</font></td>
287       </tr>
288     </table>
289     <b><font face="ÝðÞ\85" lang="zh-cn" size="6"><p align="justify"></font><font
290     face="book antiqua" size="6"><a name="_toc381201085">field details</a></p>
291     </font></b><font face="book antiqua" size="3"><p align="justify">some of the fields 
292     require some more information. the following chapters will try to provide this 
293     information:</p>
294     </font><b><font face="ÝðÞ\85" lang="zh-cn" size="5"><p></font><font face="book antiqua"
295     size="5"><a name="_toc381201086">height field</a></p>
296     </font></b><font face="book antiqua" size="3"><p align="justify">the <i>height</i> field 
297     identifies the height of the bitmap in pixels. in other words, it describes the number of 
298     scan lines of the bitmap. if this field is negative, indicating a top-down dib, the <i>compression</i> 
299     field must be either bi_rgb or bi_bitfields. top-down dibs cannot be compressed.</p>
300     </font><b><font face="ÝðÞ\85" lang="zh-cn" size="5"><p></font><font face="book antiqua"
301     size="5"><a name="_toc381201087">bits per pixel field</a></p>
302     </font></b><font face="book antiqua" size="3"><p align="justify">the <i>bits per pixel</i> 
303     (bbp) field of the bitmap file determines the number of bits that define each pixel and 
304     the maximum number of colors in the bitmap.</p>
305     </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><ul>
306       </font><font face="book antiqua" size="3"><b>
307       <li>when this field is equal to 1.</b></font></li>
308     </ul>
309     <font face="ÝðÞ\85" lang="zh-cn" size="3"><dir>
310       <dir>
311         </font><font face="book antiqua" size="3"><p align="justify">the bitmap is monochrome, and 
312         the palette contains two entries. each bit in the bitmap array represents a pixel. if the 
313         bit is clear, the pixel is displayed with the color of the first entry in the palette; if 
314         the bit is set, the pixel has the color of the second entry in the table.</p>
315         </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify">íí</p>
316       </dir>
317     </dir>
318     <ul>
319       </font><font face="book antiqua" size="3"><b>
320       <li>when this field is equal to 4.</b></font></li>
321     </ul>
322     <font face="ÝðÞ\85" lang="zh-cn" size="3"><dir>
323       <dir>
324         </font><font face="book antiqua" size="3"><p align="justify">the bitmap has a maximum of 
325         16 colors, and the palette contains up to 16 entries. each pixel in the bitmap is 
326         represented by a 4-bit index into the palette. for example, if the first byte in the 
327         bitmap is 1fh, the byte represents two pixels. the first pixel contains the color in the 
328         second palette entry, and the second pixel contains the color in the sixteenth palette 
329         entry.</p>
330         </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify">íí</p>
331       </dir>
332     </dir>
333     <ul>
334       </font><font face="book antiqua" size="3"><b>
335       <li>when this field is equal to 8.</b></font></li>
336     </ul>
337     <font face="ÝðÞ\85" lang="zh-cn" size="3"><dir>
338       <dir>
339         </font><font face="book antiqua" size="3"><p align="justify">the bitmap has a maximum of 
340         256 colors, and the palette contains up to 256 entries. in this case, each byte in the 
341         array represents a single pixel.</p>
342         <p align="justify"></font><font size="3">íí</font><font face="book antiqua" size="3"></p>
343       </dir>
344     </dir>
345     <ul>
346       <b>
347       <li>when this field is equal to 16.</b></font></li>
348     </ul>
349     <font face="ÝðÞ\85" lang="zh-cn" size="3"><dir>
350       <dir>
351         </font><font face="book antiqua" size="3"><p align="justify">the bitmap has a maximum of 
352         2^16 colors. if the <i>compression</i> field of the bitmap file is set to bi_rgb, the <i>palette</i> 
353         field does not contain any entries. each word in the bitmap array represents a single 
354         pixel. the relative intensities of red, green, and blue are represented with 5 bits for 
355         each color component. the value for blue is in the least significant 5 bits, followed by 5 
356         bits each for green and red, respectively. the most significant bit is not used.</p>
357         <p align="justify">if the <i>compression</i> field of the bitmap file is set to 
358         bi_bitfields, the <i>palette</i> field contains three dword color masks that specify the 
359         red, green, and blue components, respectively, of each pixel. each word in the bitmap 
360         array represents a single pixel.</p>
361         <b><p align="justify">windows nt specific:</b> when the <i>compression</i> field is set to 
362         bi_bitfields, bits set in each dword mask must be contiguous and should not overlap the 
363         bits of another mask. all the bits in the pixel do not have to be used. </p>
364         <b><p align="justify">windows 95 specific:</b> when the <i>compression</i> field is set to 
365         bi_bitfields, windows 95 supports only the following 16bpp color masks: a 5-5-5 16-bit 
366         image, where the blue mask is 0x001f, the green mask is 0x03e0, and the red mask is 
367         0x7c00; and a 5-6-5 16-bit image, where the blue mask is 0x001f, the green mask is 0x07e0, 
368         and the red mask is 0xf800.</p>
369         <p align="justify"></font><font size="3">íí</font><font face="book antiqua" size="3"></p>
370       </dir>
371     </dir>
372     <ul>
373       <b>
374       <li>when this field is equal to 24.</b></font></li>
375     </ul>
376     <font face="ÝðÞ\85" lang="zh-cn" size="3"><dir>
377       <dir>
378         </font><font face="book antiqua" size="3"><p align="justify">the bitmap has a maximum of 
379         2^24 colors, and the <i>palette</i> field does not contain any entries. each 3-byte 
380         triplet in the bitmap array represents the relative intensities of blue, green, and red, 
381         respectively, for a pixel.</p>
382         </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify">íí</p>
383       </dir>
384     </dir>
385     <ul>
386       </font><font face="book antiqua" size="3"><b>
387       <li>when this field is equal to 32.</b></font></li>
388     </ul>
389     <font face="ÝðÞ\85" lang="zh-cn" size="3"><dir>
390       <dir>
391         </font><font face="book antiqua" size="3"><p align="justify">the bitmap has a maximum of 
392         2^32 colors. if the <i>compression</i> field of the bitmap is set to bi_rgb, the <i>palette</i> 
393         field does not contain any entries. each dword in the bitmap array represents the relative 
394         intensities of blue, green, and red, respectively, for a pixel. the high byte in each 
395         dword is not used.</p>
396         <p align="justify">if the <i>compression</i> field of the bitmap is set to bi_bitfields, 
397         the palette field contains three dword color masks that specify the red, green, and blue 
398         components, respectively, of each pixel. each dword in the bitmap array represents a 
399         single pixel.</p>
400         <b><p align="justify">windows nt specific:</b> when the <i>compression</i> field is set to 
401         bi_bitfields, bits set in each dword mask must be contiguous and should not overlap the 
402         bits of another mask. all the bits in the pixel do not have to be used. </p>
403         <b><p align="justify">windows 95 specific:</b> when the <i>compression</i> field is set to 
404         bi_bitfields, windows 95 supports only the following 32bpp color mask: the blue mask is 
405         0x000000ff, the green mask is 0x0000ff00, and the red mask is 0x00ff0000.</font></p>
406       </dir>
407     </dir>
408     <b><font face="ÝðÞ\85" lang="zh-cn" size="5"><p></font><font face="book antiqua" size="5"><a
409     name="_toc381201088">compression field</a></p>
410     </font></b><font face="book antiqua" size="3"><p align="justify">the <i>compression</i> 
411     field specifies the way the bitmap data is stored in the file. this information together 
412     with the <i>bits per pixel</i> (<i>bpp</i>) field identifies the compression algorithm to 
413     follow.</p>
414     <p align="justify">the following values are possible in this field:</p>
415     </font><table border="1" cellspacing="2" bordercolor="#000000" cellpadding="7" width="657">
416       <tr>
417         <td width="18%" valign="top"><font face="book antiqua" size="3" color="#808080"><b><p
418         align="justify">value</b></font></td>
419         <td width="82%" valign="top"><font face="book antiqua" size="3" color="#808080"><b><p
420         align="justify">meaning</b></font></td>
421       </tr>
422       <tr>
423         <td width="18%" valign="top"><font face="book antiqua" size="3"><p align="justify">bi_rgb</font></td>
424         <td width="82%" valign="top"><font face="book antiqua" size="3"><p align="justify">an 
425         uncompressed format.</font></td>
426       </tr>
427       <tr>
428         <td width="18%" valign="top"><f>
429 <HR>
430 lign="justify">bi_rle4</font></td>
431         <td width="82%" valign="top"><font face="book antiqua" size="3"><p align="justify">an rle 
432         format for bitmaps with 4 bits per pixel. the compression format is a two-byte format 
433         consisting of a count byte followed by two word-length color indices. for more 
434         information, see the following remarks section.</font></td>
435       </tr>
436       <tr>
437         <td width="18%" valign="top"><font face="book antiqua" size="3"><p align="justify">bi_rle8</font></td>
438         <td width="82%" valign="top"><font face="book antiqua" size="3"><p align="justify">a 
439         run-length encoded (rle) format for bitmaps with 8 bits per pixel. the compression format 
440         is a two-byte format consisting of a count byte followed by a byte containing a color 
441         index. for more information, see the following remarks section.</font></td>
442       </tr>
443       <tr>
444         <td width="18%" valign="top"><font face="book antiqua" size="3"><p align="justify">bi_bitfields</font></td>
445         <td width="82%" valign="top"><font face="book antiqua" size="3"><p align="justify">specifies 
446         that the bitmap is not compressed and that the color table consists of three double word 
447         color masks that specify the red, green, and blue components, respectively, of each pixel. 
448         this is valid when used with 16- and 32- bits-per-pixel bitmaps.</font></td>
449       </tr>
450     </table>
451     <font face="book antiqua" size="3"><p align="justify">when the compression field is 
452     bi_rle8, the bitmap is compressed by using a run-length encoding (rle) format for an 8-bit 
453     bitmap. this format can be compressed in encoded or absolute modes. both modes can occur 
454     anywhere in the same bitmap.</p>
455     <ul>
456       <b>
457       <li>encoded mode consists of two bytes: </b></font></li>
458     </ul>
459     <font face="ÝðÞ\85" lang="zh-cn" size="3"><dir>
460       <dir>
461         </font><font face="book antiqua" size="3"><p align="justify">the first byte specifies the 
462         number of consecutive pixels to be drawn using the color index contained in the second 
463         byte. in addition, the first byte of the pair can be set to zero to indicate an escape 
464         that denotes an end of line, end of bitmap, or delta. the interpretation of the escape 
465         depends on the value of the second byte of the pair, which can be one of the following:</font></p>
466       </dir>
467     </dir>
468     <table cellspacing="0" border="0" cellpadding="7" width="602">
469       <tr>
470         <td width="9%" valign="top"><font face="book antiqua" size="3"><p align="justify">0</font></td>
471         <td width="91%" valign="top"><font face="book antiqua" size="3"><p align="justify">end of 
472         line.</font></td>
473       </tr>
474       <tr>
475         <td width="9%" valign="top"><font face="book antiqua" size="3"><p align="justify">1</font></td>
476         <td width="91%" valign="top"><font face="book antiqua" size="3"><p align="justify">end of 
477         bitmap.</font></td>
478       </tr>
479       <tr>
480         <td width="9%" valign="top"><font face="book antiqua" size="3"><p align="justify">2</font></td>
481         <td width="91%" valign="top"><font face="book antiqua" size="3"><p align="justify">delta. 
482         the two bytes following the escape contain unsigned values indicating the horizontal and 
483         vertical offsets of the next pixel from the current position.</font></td>
484       </tr>
485     </table>
486     <font face="ÝðÞ\85" lang="zh-cn" size="3"><ul>
487       </font><font face="book antiqua" size="3"><b>
488       <li>absolute mode.</b></font></li>
489     </ul>
490     <font face="ÝðÞ\85" lang="zh-cn" size="3"><dir>
491       <dir>
492         </font><font face="book antiqua" size="3"><p align="justify">the first byte is zero and 
493         the second byte is a value in the range 03h through ffh. the second byte represents the 
494         number of bytes that follow, each of which contains the color index of a single pixel. 
495         when the second byte is 2 or less, the escape has the same meaning as in encoded mode. in 
496         absolute mode, each run must be aligned on a word boundary.</p>
497         </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify">íí</p>
498         <p align="justify"></font>íí</p>
499       </dir>
500     </dir>
501     <font face="book antiqua" size="3"><p align="justify">the following example shows the 
502     hexadecimal values of an 8-bit compressed bitmap.</p>
503     </font><font face="courier new" size="3"><p align="justify">03 04 05 06 00 03 45 56 67 00 
504     02 78 00 02 05 01 02 78 00 00 09 1e 00 01</p>
505     </font><font face="book antiqua" size="3"><p align="justify">this bitmap would expand as 
506     follows (two-digit values represent a color index for a single pixel):</p>
507     </font><font face="courier new" size="3"><p align="justify">04 04 04</p>
508     <p align="justify">06 06 06 06 06</p>
509     <p align="justify">45 56 67</p>
510     <p align="justify">78 78</p>
511     <p align="justify">move current position 5 right and 1 down</p>
512     <p align="justify">78 78</p>
513     <p align="justify">end of line</p>
514     <p align="justify">1e 1e 1e 1e 1e 1e 1e 1e 1e</p>
515     <p align="justify">end of rle bitmap</p>
516     </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify">íí</p>
517     </font><font face="book antiqua" size="3"><p align="justify">when the compression field is 
518     bi_rle4, the bitmap is compressed by using a run-length encoding format for a 4-bit 
519     bitmap, which also uses encoded and absolute modes:</p>
520     <ul>
521       <b>
522       <li>in encoded mode.</b></font></li>
523     </ul>
524     <font face="ÝðÞ\85" lang="zh-cn" size="3"><dir>
525       <dir>
526         </font><font face="book antiqua" size="3"><p align="justify">the first byte of the pair 
527         contains the number of pixels to be drawn using the color indices in the second byte. the 
528         second byte contains two color indices, one in its high-order four bits and one in its 
529         low-order four bits. the first of the pixels is drawn using the color specified by the 
530         high-order four bits, the second is drawn using the color in the low-order four bits, the 
531         third is drawn using the color in the high-order four bits, and so on, until all the 
532         pixels specified by the first byte have been drawn.</p>
533         </font><font face="ÝðÞ\85" lang="zh-cn" size="3">
534       </dir>
535     </dir>
536     <ul>
537       </font><font face="book antiqua" size="3"><b>
538       <li>in absolute mode. </b></font></li>
539     </ul>
540     <font face="ÝðÞ\85" lang="zh-cn" size="3"><dir>
541       <dir>
542         </font><font face="book antiqua" size="3"><p align="justify">the first byte is zero, the 
543         second byte contains the number of color indices that follow, and subsequent bytes contain 
544         color indices in their high- and low-order four bits, one color index for each pixel. in 
545         absolute mode, each run must be aligned on a word boundary. </p>
546         <p align="justify">the end-of-line, end-of-bitmap, and delta escapes described for bi_rle8 
547         also apply to bi_rle4 compression.</p>
548         </font><font face="ÝðÞ\85" lang="zh-cn" size="3"><p align="justify"></font>íí</p>
549       </dir>
550     </dir>
551     <font face="book antiqua" size="3"><p align="justify">the following example shows the 
552     hexadecimal values of a 4-bit compressed bitmap.</p>
553     </font><font face="courier new" size="3"><p align="justify">03 04 05 06 00 06 45 56 67 00 
554     04 78 00 02 05 01 04 78 00 00 09 1e 00 01</p>
555     </font><font face="book antiqua" size="3"><p align="justify">this bitmap would expand as 
556     follows (single-digit values represent a color index for a single pixel):</p>
557     </font><font face="courier new" size="3"><p align="justify">0 4 0</p>
558     <p align="justify">0 6 0 6 0</p>
559     <p align="justify">4 5 5 6 6 7</p>
560     <p align="justify">7 8 7 8</p>
561     <p align="justify">move current position 5 right and 1 down</p>
562     <p align="justify">7 8 7 8</p>
563     <p align="justify">end of line</p>
564     <p align="justify">1 e 1 e 1 e 1 e 1</p>
565     <p align="justify">end of rle bitmap</p>
566     </font><b><font face="ÝðÞ\85" lang="zh-cn" size="5"><p></font><font face="book antiqua"
567     size="5"><a name="_toc381201089">colors field</a></p>
568     </font></b><font face="book antiqua" size="3"><p align="justify">the <i>colors</i> field 
569     specifies the number of color indices in the color table that are actually used by the 
570     bitmap. if this value is zero, the bitmap uses the maximum number of colors corresponding 
571     to the value of the <i>bbp</i> field for the compression mode specified by the <i>compression</i> 
572     field. </p>
573     <p align="justify">if the <i>colors</i> field is nonzero and the <i>bbp</i> field less 
574     than 16, the <i>colors</i> field specifies the actual number of colors the graphics engine 
575     or device driver accesses. </p>
576     <p align="justify">if the <i>bbp</i> field is 16 or greater, then <i>colors</i> field 
577     specifies the size of the color table used to optimize performance of windows color 
578     palettes. </p>
579     <p align="justify">if <i>bbp</i> equals 16 or 32, the optimal color palette starts 
580     immediately following the three double word masks.</p>
581     <p align="justify">if the bitmap is a packed bitmap (a bitmap in which the bitmap array 
582     immediately follows the bitmap header and which is referenced by a single pointer), the <i>colors</i> 
583     field must be either 0 or the actual size of the color table. </p>
584     </font><b><font face="ÝðÞ\85" lang="zh-cn" size="5"><p></font><font face="book antiqua"
585     size="5"><a name="_toc381201090">important colors field</a></p>
586     </font></b><font face="arial" size="3"><p align="justify">the <i>important colors</i> 
587     field s</font><font face="book antiqua" size="3">pecifies the number of color indices that 
588     are considered important for displaying the bitmap. if this value is zero, all colors are 
589     important. </font></td>
590   </tr>
591 </table>
592 </center></div>
593 <p>
594 atlc is written and supported by <a href="jpgs/home-email.jpg">Dr. David Kirkby (G8WRB)</A><p>
595 <a href="http://atlc.sourceforge.net">Return to the atlc homepage</a>
596 <a href="http://homepage.ntlworld.com/drkirkby/list1.html"></a>
597 <a href="http://homepage.ntlworld.com/drkirkby/list2.html"></a>
598 <a href="http://homepage.ntlworld.com/drkirkby/list3.html"></a>
599 <a href="http://homepage.ntlworld.com/drkirkby/list4.html"></a>
600 <a href="http://homepage.ntlworld.com/drkirkby/list5.html"></a>
601 <a href="http://homepage.ntlworld.com/drkirkby/list6.html"></a>
602 <a href="http://homepage.ntlworld.com/drkirkby/list7.html"></a>
603 <BR>
604 <BR>
605 <A href="http://sourceforge.net"> <IMG
606 src="http://sourceforge.net/sflogo.php?group_id=25836&amp;type=5"
607 width="210" height="62" border="0" alt="SourceForge.net
608 Logo"></A>
609 </body>
610 </html>