![]() ![]() The end-of-line, end-of-bitmap, and delta escapes described for BI_RLE8 also apply to BI_RLE4 compression. In absolute mode, each run must be aligned on a word boundary. Subsequent bytes contain color indexes in their high- and low-order 4 bits, one color index for each pixel. The second byte contains the number of color indexes that follow. In absolute mode, the first byte is zero.The first of the pixels is drawn using the color specified by the high-order 4 bits, the second is drawn using the color in the low-order 4 bits, the third is drawn using the color in the high-order 4 bits, and so on, until all the pixels specified by the first byte have been drawn. Most binary images also compress well with simple run-length compression schemes. Because of the small size of the image files, fax machine and document management solutions usually use this format. A 640×480 image requires 37.5 KiB of storage. The second byte contains two color indexes, one in its high-order 4 bits and one in its low-order 4 bits. A binary image can be stored in memory as a bitmap, a packed array of bits. In encoded mode, the first byte of the pair contains the number of pixels to be drawn using the color indexes in the second byte. ![]() When the Compression member is BI_RLE4, the bitmap is compressed by using a run-length encoding format for a 4-bit bitmap, which also uses encoded and absolute modes: The bitmap expands as follows (two-digit values represent a color index for a single pixel): 04 04 04 The following example shows the hexadecimal values of an 8-bit compressed bitmap: In absolute mode, each run must be zero-padded to end on a 16-bit word boundary. A nil value is returned for other non-standard bitmap types. For 64-bit RGBA images, conversion is done by dividing each 16-bit channel by 256. When the second byte is two or less, the escape has the same meaning as encoded mode. For 48-bit RGB images, conversion is done by dividing each 16-bit channel by 256 and by setting the alpha channel to an opaque value (0xFF). The second byte represents the number of bytes that follow, each of which contains the color index of a single pixel. In absolute mode, the first byte is zero and the second byte is a value in the range 03H through FFH.The 2 bytes following the escape contain unsigned values indicating the offset to the right and up of the next pixel from the current position. The interpretation of the escape depends on the value of the second byte of the pair, which can be one of the following values.ĭelta. In addition, the first byte of the pair can be set to zero to indicate an escape character that denotes the end of a line, the end of a bitmap, or a delta, depending on the value of the second byte. Encoded mode consists of two bytes: the first byte specifies the number of consecutive pixels to be drawn using the color index contained in the second byte.Both modes can occur anywhere in the same bitmap: This format can be compressed in encoded or absolute modes. When the Compression member of the bitmap information header structure is BI_RLE8, a run-length encoding (RLE) format is used to compress an 8-bit bitmap. Compression reduces the disk and memory storage required for the bitmap. Windows supports formats for compressing bitmaps that define their colors with 8 or 4 bits-per-pixel.
0 Comments
Leave a Reply. |