How to display bitmap

Source: Internet
Author: User

 

 

Bitmap files are divided into four parts. The first part is the bitmap file header, which includes the bitmap file name, bitmap size, and the offset of the bitmap data from the file header. The next step is the bitmap information header, which includes many information about the bitmap, such as the bitmap width, height, and the number of colors used by the bitmap. Next is the color table, which may contain two or more RGBQUAD structures. The last side is the data of the bitmap image.

 

IThe bitmap structure is as follows:

---- 1. BMP file structure

 

---- 1. BMP file Composition

---- A bmp file consists of four parts: File Header, bitmap information header, color information, and graphic data.

 

---- 2. BMP File Header

---- The data structure of the BMP file header contains information such as the type, size, and start position of the BMP file.

---- Its structure is defined as follows:

 

Typedef struct tagBITMAPFILEHEADER

{

WORDbfType;// The type of the bitmap file, which must be BM

DWORDBfSize;// Bitmap file size, in bytes

WORDbfReserved1;// Reserved words for bitmap files, which must be 0

WORDbfReserved2;// Reserved words for bitmap files, which must be 0

DWORDBfOffBits; // the starting position of the bitmap data, relative to the bitmap

// The offset of the file header, in bytes

} BITMAPFILEHEADER;

 

---- 3. Bitmap header

 

The BMP Bitmap header is used to describe the size and other information of the bitmap.

Typedef struct tagBITMAPINFOHEADER {

DWORDBiSize;// The number of bytes occupied by this structure

LONGbiWidth;// Bitmap width, in pixels

LONGbiHeight; // The height of the bitmap, in pixels

 WORDBiPlanes; // The level of the target device, which must be 1

WORDBiBitCount // The number of digits required for each pixel, which must be 1 (two-color ),

// 4 (16 colors), 8 (256 colors), or 24 (true color)

DWORDBiCompression;// Bitmap compression type, which must be 0 (not compressed ),

// 1 (BI_RLE8 compression type) or 2 (BI_RLE4 compression type)

DWORDBiSizeImage; // The bitmap size, in bytes.

LONGbiXPelsPerMeter; // horizontal bitmap resolution, number of workers per meter

LONGbiYPelsPerMeter;// Bitmap vertical resolution, number of workers per meter

DWORDBiClrUsed; // The number of colors in the color table used by the bitmap.

DWORDBiClrImportant; // number of important colors in the bitmap display process

} BITMAPINFOHEADER;

 

---- 4. Color Table

 

A color table is used to describe the color in a bitmap. It has several table items. Each table item is an RGBQUAD-type structure and defines a color. The RGBQUAD structure is defined as follows:

 

Typedef struct tagRGBQUAD {

BYTErgbBlue; // blue brightness (value range: 0-255)

BYTErgbGreen;// Green brightness (value range: 0-255)

BYTErgbRed; // The Red brightness (value range: 0-255)

BYTErgbReserved; // reserved, must be 0

} RGBQUAD;

Color TableThe number of RGBQUAD structure data is determined by biBitCount:

WhenBiBitCount = 256, 8, there are, table items;

WhenBiBitCount = 24, there is no color table item.

The bitmap information header and the color table form bitmap information. The BITMAPINFO structure is defined as follows:

Typedef struct tagBITMAPINFO {

BITMAPINFOHEADER bmiHeader;// Bitmap header

RGBQUADBmiColors [1];// Color table

} BITMAPINFO;

 

---- 5. bitmap data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.