Graphics File Formats(Windows的.BMP .CUR .ICO文件的格式,有范例)
03 04 04 04 04 05 06 06 06 06 06 06 00 03 45 56 67 00 45 56 67 02 78 78 78 00 02 05 01 move 5 right and 1 down 02 78 78 78 00 00 end of line 09 1e 1e 1e 1e 1e 1e 1e 1e 1e 1e 00 01 end of rle bitmap
compression of 4-bits-per-pixel bitmaps
when the bicompression member of the bitmapinfoheader structure is set to bi_rle4, the dib is compressed using a run-length encoded format for a 16-color bitmap. this format uses two modes: encoded mode and absolute mode.
encoded mode
a unit of information in encoded mode consists of two bytes. the first byte of the pair contains the number of pixels to be drawn using the color indexes in the second byte.
the second byte contains two color indexes, one in its high-order nibble (that is, its low-order 4 bits) and one in its low-order nibble.
the first pixel is drawn using the color specified by the high-order nibble, the second is drawn using the color in the low-order nibble, the third is drawn with the color in the high-order nibble, and so on, until all the pixels specified by the first byte have been drawn.
the first byte of the pair can be set to zero to indicate an escape that denotes the end of a line, the end of the bitmap, or a delta. the interpretation of the escape depends on the value of the second byte of the pair. in encoded mode, the second byte has a value in the range 0x00 through 0x02. the meaning of these values is the same as for a dib with 8 bits per pixel.
absolute mode
in absolute mode, the first byte contains zero, the second byte contains the number of color indexes that follow, and subsequent bytes contain color indexes in their high- and low-order nibbles, one color index for each pixel. each run must be aligned on a word boundary.
following is an example of a 4-bit rle bitmap (the one-digit hexadecimal values in the second column represent a color index for a single pixel):
compressed data expanded data
03 04 0 4 0 05 06 0 6 0 6 0 00 06 45 56 67 00 4 5 5 6 6 7 04 78 7 8 7 8 00 02 05 01 move 5 right and 1 down 04 78 7 8 7 8 00 00 end of line 09 1e 1 e 1 e 1 e 1 e 1 00 01 end of rle bitmap
bitmap example
the following example is a text dump of a 16-color bitmap (4 bits per pixel):
win3dibfile bitmapfileheader type 19778 size 3118 reserved1 0 reserved2 0 offsetbits 118 bitmapinfoheader size 40 width 80 height 75 planes 1 bitcount 4 compression 0 sizeimage 3000
xpelspermeter 0 ypelspermeter 0 colorsused 16 colorsimportant 16 win3colortable blue green red unused [00000000] 84 252 84 0 [00000001] 252 252 84 0 [00000002] 84 84 252 0 [00000003] 252 84 252 0 [00000004] 84 252 252 0 [00000005] 252 252 252 0 [00000006] 0 0 0 0 [00000007] 168 0 0 0 [00000008] 0 168 0 0 [00000009] 168 168 0 0 [0000000a] 0 0 168 0 [0000000b] 168 0 168 0 [0000000c] 0 168 168 0 [0000000d] 168 168 168 0 [0000000e] 84 84 84 0 [0000000f] 252 84 84 0 image . . bitmap data .
icon-resource file format
an icon-resource file contains image data for icons used by windows applications. the file consists of an icon directory identifying the number and types of icon images in the file, plus one or more icon images. the |