📄 bmp.htm
字号:
layout of a device-independent bitmap (dib) file.<br>
<br>
member description<br>
<br>
bftype specifies the type of file. this member must be bm. <br>
bfsize specifies the size of the file, in bytes. <br>
bfreserved1 reserved; must be set to zero. <br>
bfreserved2 reserved; must be set to zero.<br>
bfoffbits specifies the byte offset from the bitmapfileheader structure<br>
to the actual bitmap data in the file.<br>
<br>
comments<br>
<br>
a bitmapinfo or bitmapcoreinfo structure immediately follows the<br>
bitmapfileheader structure in the dib file.<br>
<br>
see also<br>
<br>
bitmapcoreinfo, bitmapinfo <br>
<br>
<br>
==============================================================================<br>
bitmapinfo (3.0)<br>
<br>
<br>
<br>
typedef struct tagbitmapinfo { /* bmi */<br>
bitmapinfoheader bmiheader;<br>
rgbquad bmicolors[1];<br>
} bitmapinfo;<br>
<br>
the bitmapinfo structure fully defines the dimensions and color information<br>
for a windows 3.0 or later device-independent bitmap (dib).<br>
<br>
member description<br>
<br>
bmiheader specifies a bitmapinfoheader structure that contains<br>
information about the dimensions and color format of a dib.<br>
<br>
bmicolors specifies an array of rgbquad structures that define the<br>
colors in the bitmap.<br>
<br>
comments<br>
<br>
a windows 3.0 or later dib consists of two distinct parts: a bitmapinfo<br>
structure, which describes the dimensions and colors of the bitmap, and an<br>
array of bytes defining the pixels of the bitmap. the bits in the array are<br>
packed together, but each scan line must be zero-padded to end on a long<br>
boundary. segment boundaries, however, can appear anywhere in the bitmap. the<br>
origin of the bitmap is the lower-left corner.<br>
<br>
the bibitcount member of the bitmapinfoheader structure determines the number<br>
of bits which define each pixel and the maximum number of colors in the<br>
bitmap. this member may be set to any of the following values:<br>
<br>
value meaning<br>
<br>
1 the bitmap is monochrome, and the bmcicolors member must contain two<br>
entries. each bit in the bitmap array represents a pixel. if the bit is<br>
clear, the pixel is displayed with the color of the first entry in the<br>
bmcicolors table. if the bit is set, the pixel has the color of the second<br>
entry in the table.<br>
<br>
4 the bitmap has a maximum of 16 colors, and the bmcicolors member<br>
contains 16 entries. each pixel in the bitmap is represented by a four-bit<br>
index into the color table.<br>
<br>
for example, if the first byte in the bitmap is 0x1f, the byte represents two<br>
pixels. the first pixel contains the color in the second table entry, and the<br>
second pixel contains the color in the sixteenth table entry.<br>
<br>
8 the bitmap has a maximum of 256 colors, and the bmcicolors member<br>
contains 256 entries. in this case, each byte in the array represents a<br>
single pixel.<br>
<br>
24 the bitmap has a maximum of 2^24 colors. the bmcicolors member is<br>
null, and each 3-byte sequence in the bitmap array represents the relative<br>
intensities of red, green, and blue, respectively, of 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.<br>
<br>
the colors in the bmicolors table should appear in order of importance.<br>
alternatively, for functions that use dibs, the bmicolors member can be an<br>
array of 16-bit unsigned integers that specify an index into the currently<br>
realized logical palette instead of explicit rgb values. in this case, an<br>
application using the bitmap must call dib functions with the wusage<br>
parameter set to dib_pal_colors.<br>
<br>
note: the bmicolors member should not contain palette indexes if the bitmap<br>
is to be stored in a file or transferred to another application. unless the<br>
application uses the bitmap exclusively and under its complete control, the<br>
bitmap color table should contain explicit rgb values.<br>
<br>
see also<br>
<br>
bitmapinfoheader, rgbquad <br>
<br>
==============================================================================<br>
bitmapinfoheader (3.0)<br>
<br>
<br>
<br>
typedef struct tagbitmapinfoheader { /* bmih */<br>
dword bisize;<br>
long biwidth;<br>
long biheight;<br>
word biplanes;<br>
word bibitcount;<br>
dword bicompression;<br>
dword bisizeimage;<br>
long bixpelspermeter;<br>
long biypelspermeter;<br>
dword biclrused;<br>
dword biclrimportant;<br>
} bitmapinfoheader;<br>
<br>
the bitmapinfoheader structure contains information about the dimensions and<br>
color format of a windows 3.0 or later device-independent bitmap (dib).<br>
<br>
member description<br>
<br>
bisize specifies the number of bytes required by the<br>
bitmapinfoheader structure.<br>
<br>
biwidth specifies the width of the bitmap, in pixels. <br>
biheightspecifies the height of the bitmap, in pixels. <br>
<br>
biplanesspecifies the number of planes for the target device. this<br>
member must be set to 1.<br>
<br>
bibitcount specifies the number of bits per pixel. this value must be 1,<br>
4, 8, or 24.<br>
<br>
bicompression specifies the type of compression for a compressed bitmap. it<br>
can be one of the following values:<br>
<br>
value meaning<br>
<br>
bi_rgb specifies that the bitmap is not compressed. <br>
<br>
bi_rle8 specifies a run-length encoded format for bitmaps with 8 bits<br>
per pixel. the compression format is a 2-byte format consisting of a count<br>
byte followed by a byte containing a color index. for more information, see<br>
the following comments section.<br>
<br>
bi_rle4 specifies a run-length encoded format for bitmaps with 4 bits<br>
per pixel. the compression format is a 2-byte format consisting of a count<br>
byte followed by two word-length color indexes. for more information, see<br>
the following comments section.<br>
<br>
bisizeimage specifies the size, in bytes, of the image. it is valid to<br>
set this member to zero if the bitmap is in the bi_rgb format.<br>
<br>
bixpelspermeter specifies the horizontal resolution, in pixels per meter, of<br>
the target device for the bitmap. an application can use this value to select<br>
a bitmap from a resource group that best matches the characteristics of the<br>
current device.<br>
<br>
biypelspermeter specifies the vertical resolution, in pixels per meter, of<br>
the target device for the bitmap.<br>
<br>
biclrused specifies the number of color indexes in the color table<br>
actually used by the bitmap. if this value is zero, the bitmap uses the<br>
maximum number of colors corresponding to the value of the bibitcount member.<br>
for more information on the maximum sizes of the color table, see the<br>
description of the bitmapinfo structure earlier in this topic.<br>
<br>
if the biclrused member is nonzero, it specifies the actual number of colors<br>
that the graphics engine or device driver will access if the bibitcount<br>
member is less than 24. if bibitcount is set to 24, biclrused specifies the<br>
size of the reference color table used to optimize performance of windows<br>
color palettes. if the bitmap is a packed bitmap (that is, a bitmap in which<br>
the bitmap array immediately follows the bitmapinfo header and which is<br>
referenced by a single pointer), the biclrused member must be set to zero or<br>
to the actual size of the color table.<br>
<br>
biclrimportant specifies the number of color indexes that are considered<br>
important for displaying the bitmap. if this value is zero, all colors are<br>
important.<br>
<br>
comments<br>
<br>
the bitmapinfo structure combines the bitmapinfoheader structure and a color<br>
table to provide a complete definition of the dimensions and colors of a<br>
windows 3.0 or later dib. for more information about specifying a windows 3.0<br>
dib, see the description of the bitmapinfo structure.<br>
<br>
an application should use the information stored in the bisize member to<br>
locate the color table in a bitmapinfo structure as follows:<br>
<br>
pcolor = ((lpstr) pbitmapinfo + (word) (pbitmapinfo->bmiheader.bisize))<br>
<br>
windows supports formats for compressing bitmaps that define their colors<br>
with 8 bits per pixel and with 4 bits per pixel. compression reduces the disk<br>
and memory storage required for the bitmap. the following paragraphs describe<br>
these formats.<br>
<br>
bi_rle8<br>
<br>
when the bicompression member is set to bi_rle8, the bitmap is compressed<br>
using a run-length encoding format for an 8-bit bitmap. this format may be<br>
compressed in either of two modes: encoded and absolute. both modes can occur<br>
anywhere throughout a single bitmap.<br>
<br>
encoded mode consists of two bytes: the first byte specifies the number of<br>
consecutive pixels to be drawn using the color index contained in the second<br>
byte. in addition, the first byte of the pair can be set to zero to indicate<br>
an escape that denotes an end of line, end of bitmap, or a delta. the<br>
interpretation of the escape depends on the value of the second byte of the<br>
pair. the following list shows the meaning of the second byte:<br>
<br>
value 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 offset of the next pixel from the<br>
current position.<br>
<br>
absolute mode is signaled by the first byte set to zero and the second byte<br>
set to a value between 0x03 and 0xff. in absolute mode, the second byte<br>
represents the number of bytes that follow, each of which contains the color<br>
index of a single pixel. when the second byte is set to 2 or less, the escape<br>
has the same meaning as in encoded mode. in absolute mode, each run must be<br>
aligned on a word boundary. the following example shows the hexadecimal<br>
values of an 8-bit compressed bitmap:<br>
<br>
<br>
<br>
03 04 05 06 00 03 45 56 67 00 02 78 00 02 05 01<br>
02 78 00 00 09 1e 00 01<br>
<br>
this bitmap would expand as follows (two-digit values represent a color index<br>
for a single pixel):<br>
<br>
<br>
<br>
04 04 04<br>
06 06 06 06 06<br>
45 56 67<br>
78 78<br>
move current position 5 right and 1 down<br>
78 78<br>
end of line<br>
1e 1e 1e 1e 1e 1e 1e 1e 1e<br>
end of rle bitmap<br>
<br>
bi_rle4<br>
<br>
when the bicompression member is set to bi_rle4, the bitmap is compressed<br>
using a run-length encoding (rle) format for a 4-bit bitmap, which also uses<br>
encoded and absolute modes. in encoded mode, the first byte of the pair<br>
contains the number of pixels to be drawn using the color indexes in the<br>
second byte. the second byte contains two color indexes, one in its<br>
high-order nibble (that is, its low-order four bits) and one in its low-order<br>
nibble. the first of the pixels is drawn using the color specified by the<br>
high-order nibble, the second is drawn using the color in the low-order<br>
nibble, the third is drawn with the color in the high-order nibble, and so<br>
on, until all the pixels specified by the first byte have been drawn. in<br>
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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -