📄 bmp.htm
字号:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>graphics file formats</title>
<meta name="generator" content="microsoft frontpage 3.0">
</head>
<body background="../jpg/di1.JPG">
<p align="center"><font size="6" color="#0000ff">graphics file formats</font></p>
<div align="center"><center>
<table border="0" width="88%">
<tr>
<td width="100%" height="148"><br>
<br>
this topic describes the graphics-file formats used by the microsoft windows<br>
operating system. graphics files include bitmap files, icon-resource files,<br>
and cursor-resource files.<br>
<br>
bitmap-file formats<br>
<br>
windows bitmap files are stored in a device-independent bitmap (dib) format<br>
that allows windows to display the bitmap on any type of display device. the<br>
term "device independent" means that the bitmap specifies pixel color in a<br>
form independent of the method used by a display to represent color. the<br>
default filename extension of a windows dib file is .bmp.<br>
<br>
bitmap-file structures<br>
<br>
each bitmap file contains a bitmap-file header, a bitmap-information header,<br>
a color table, and an array of bytes that defines the bitmap bits. the file<br>
has the following form:<br>
<br>
bitmapfileheader bmfh;<br>
bitmapinfoheader bmih;<br>
rgbquad acolors[];<br>
byte abitmapbits[];<br>
<br>
the bitmap-file header contains information about the type, size, and layout<br>
of a device-independent bitmap file. the header is defined as a<br>
bitmapfileheader structure.<br>
<br>
the bitmap-information header, defined as a bitmapinfoheader structure,<br>
specifies the dimensions, compression type, and color format for the bitmap.<br>
<br>
the color table, defined as an array of rgbquad structures, contains as many<br>
elements as there are colors in the bitmap. the color table is not present<br>
for bitmaps with 24 color bits because each pixel is represented by 24-bit<br>
red-green-blue (rgb) values in the actual bitmap data area. the colors in the<br>
table should appear in order of importance. this helps a display driver<br>
render a bitmap on a device that cannot display as many colors as there are<br>
in the bitmap. if the dib is in windows version 3.0 or later format, the<br>
driver can use the biclrimportant member of the bitmapinfoheader structure to<br>
determine which colors are important.<br>
<br>
the bitmapinfo structure can be used to represent a combined<br>
bitmap-information header and color table. the bitmap bits, immediately<br>
following the color table, consist of an array of byte values representing<br>
consecutive rows, or "scan lines," of the bitmap. each scan line consists of<br>
consecutive bytes representing the pixels in the scan line, in left-to-right<br>
order. the number of bytes representing a scan line depends on the color<br>
format and the width, in pixels, of the bitmap. if necessary, a scan line<br>
must be zero-padded to end on a 32-bit boundary. however, segment boundaries<br>
can appear anywhere in the bitmap. the scan lines in the bitmap are stored<br>
from bottom up. this means that the first byte in the array represents the<br>
pixels in the lower-left corner of the bitmap and the last byte represents<br>
the pixels in the upper-right corner.<br>
<br>
the bibitcount member of the bitmapinfoheader structure determines the number<br>
of bits that define each pixel and the maximum number of colors in the<br>
bitmap. these members can have any of the following values:<br>
<br>
value meaning<br>
<br>
1 bitmap is monochrome and the color table contains two entries. each<br>
bit in the bitmap array represents a pixel. if the bit is clear, the pixel is<br>
displayed with the color of the first entry in the color table. if the bit is<br>
set, the pixel has the color of the second entry in the table.<br>
<br>
4 bitmap has a maximum of 16 colors. each pixel in the bitmap is<br>
represented by a 4-bit index into the color table. for example, if the first<br>
byte in the bitmap is 0x1f, the byte represents two pixels. the first pixel<br>
contains the color in the second table entry, and the second pixel contains<br>
the color in the sixteenth table entry.<br>
<br>
8 bitmap has a maximum of 256 colors. each pixel in the bitmap is<br>
represented by a 1-byte index into the color table. for example, if the first<br>
byte in the bitmap is 0x1f, the first pixel has the color of the<br>
thirty-second table entry.<br>
<br>
24 bitmap has a maximum of 2^24 colors. the bmicolors (or bmcicolors)<br>
member is null, and each 3-byte sequence in the bitmap array represents the<br>
relative intensities of red, green, and blue, respectively, for a pixel.<br>
<br>
the biclrused member of the bitmapinfoheader structure specifies the number<br>
of color indexes in the color table actually used by the bitmap. if the<br>
biclrused member is set to zero, the bitmap uses the maximum number of colors<br>
corresponding to the value of the bibitcount member. an alternative form of<br>
bitmap file uses the bitmapcoreinfo, bitmapcoreheader, and rgbtriple<br>
structures.<br>
<br>
bitmap compression<br>
<br>
windows versions 3.0 and later support run-length encoded (rle) formats for<br>
compressing bitmaps that use 4 bits per pixel and 8 bits per pixel.<br>
compression reduces the disk and memory storage required for a bitmap.<br>
<br>
compression of 8-bits-per-pixel bitmaps<br>
<br>
when the bicompression member of the bitmapinfoheader structure is set to<br>
bi_rle8, the dib is compressed using a run-length encoded format for a<br>
256-color bitmap. this format uses two modes: encoded mode and absolute mode.<br>
both modes can occur anywhere throughout a single bitmap.<br>
<br>
encoded mode<br>
<br>
a unit of information in encoded mode consists of two bytes. the first byte<br>
specifies the number of consecutive pixels to be drawn using the color index<br>
contained in the second byte. the first byte of the pair can be set to zero<br>
to indicate an escape that denotes the end of a line, the end of the bitmap,<br>
or a delta. the interpretation of the escape depends on the value of the<br>
second byte of the pair, which must be in the range 0x00 through 0x02.<br>
following are the meanings of the escape values that can be used in the<br>
second byte:<br>
<br>
second byte meaning<br>
<br>
0 end of line. <br>
1 end of bitmap. <br>
2 delta. the two bytes following the escape contain unsigned values<br>
indicating the horizontal and vertical offsets of the next pixel from the<br>
current position.<br>
<br>
absolute mode<br>
<br>
absolute mode is signaled by the first byte in the pair being set to zero and<br>
the second byte to a value between 0x03 and 0xff. the second byte represents<br>
the number of bytes that follow, each of which contains the color index of a<br>
single pixel. each run must be aligned on a word boundary. following is an<br>
example of an 8-bit rle bitmap (the two-digit hexadecimal values in the<br>
second column represent a color index for a single pixel):<br>
<br>
compressed data expanded data<br>
<br>
03 04 04 04 04 <br>
05 06 06 06 06 06 06 <br>
00 03 45 56 67 00 45 56 67 <br>
02 78 78 78 <br>
00 02 05 01 move 5 right and 1 down <br>
02 78 78 78 <br>
00 00 end of line <br>
09 1e 1e 1e 1e 1e 1e 1e 1e 1e 1e <br>
00 01 end of rle bitmap <br>
<br>
compression of 4-bits-per-pixel bitmaps<br>
<br>
when the bicompression member of the bitmapinfoheader structure is set to<br>
bi_rle4, the dib is compressed using a run-length encoded format for a<br>
16-color bitmap. this format uses two modes: encoded mode and absolute mode.<br>
<br>
encoded mode<br>
<br>
a unit of information in encoded mode consists of two bytes. the first byte<br>
of the pair contains the number of pixels to be drawn using the color indexes<br>
in the second byte.<br>
<br>
the second byte contains two color indexes, one in its high-order nibble<br>
(that is, its low-order 4 bits) and one in its low-order nibble.<br>
<br>
the first pixel is drawn using the color specified by the high-order nibble,<br>
the second is drawn using the color in the low-order nibble, the third is<br>
drawn with the color in the high-order nibble, and so on, until all the<br>
pixels specified by the first byte have been drawn.<br>
<br>
the first byte of the pair can be set to zero to indicate an escape that<br>
denotes the end of a line, the end of the bitmap, or a delta. the<br>
interpretation of the escape depends on the value of the second byte of the<br>
pair. in encoded mode, the second byte has a value in the range 0x00 through<br>
0x02. the meaning of these values is the same as for a dib with 8 bits per<br>
pixel.<br>
<br>
absolute mode<br>
<br>
in absolute mode, the first byte contains zero, the second byte contains the<br>
number of color indexes that follow, and subsequent bytes contain color<br>
indexes in their high- and low-order nibbles, one color index for each pixel.<br>
each run must be aligned on a word boundary.<br>
<br>
following is an example of a 4-bit rle bitmap (the one-digit hexadecimal<br>
values in the second column represent a color index for a single pixel):<br>
<br>
compressed data expanded data<br>
<br>
03 04 0 4 0<br>
05 06 0 6 0 6 0 <br>
00 06 45 56 67 00 4 5 5 6 6 7 <br>
04 78 7 8 7 8 <br>
00 02 05 01 move 5 right and 1 down <br>
04 78 7 8 7 8 <br>
00 00 end of line <br>
09 1e 1 e 1 e 1 e 1 e 1 <br>
00 01 end of rle bitmap <br>
<br>
bitmap example<br>
<br>
the following example is a text dump of a 16-color bitmap (4 bits per pixel):<br>
<br>
win3dibfile<br>
bitmapfileheader<br>
type 19778<br>
size 3118<br>
reserved1 0<br>
reserved2 0<br>
offsetbits 118<br>
bitmapinfoheader<br>
size 40<br>
width 80<br>
height 75<br>
planes 1<br>
bitcount 4<br>
compression 0<br>
sizeimage 3000<br>
<br>
xpelspermeter 0<br>
ypelspermeter 0<br>
colorsused 16<br>
colorsimportant 16<br>
win3colortable<br>
blue green red unused<br>
[00000000] 84 252 84 0<br>
[00000001] 252 252 84 0<br>
[00000002] 84 84 252 0<br>
[00000003] 252 84 252 0<br>
[00000004] 84 252 252 0<br>
[00000005] 252 252 252 0<br>
[00000006] 0 0 0 0<br>
[00000007] 168 0 0 0<br>
[00000008] 0 168 0 0<br>
[00000009] 168 168 0 0<br>
[0000000a] 0 0 168 0<br>
[0000000b] 168 0 168 0<br>
[0000000c] 0 168 168 0<br>
[0000000d] 168 168 168 0<br>
[0000000e] 84 84 84 0<br>
[0000000f] 252 84 84 0<br>
image<br>
.<br>
. bitmap data<br>
.<br>
<br>
icon-resource file format<br>
<br>
an icon-resource file contains image data for icons used by windows<br>
applications. the file consists of an icon directory identifying the number<br>
and types of icon images in the file, plus one or more icon images. the<br>
default filename extension for an icon-resource file is .ico.<br>
<br>
icon directory<br>
<br>
each icon-resource file starts with an icon directory. the icon directory,<br>
defined as an icondir structure, specifies the number of icons in the<br>
resource and the dimensions and color format of each icon image. the icondir<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -