Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit focus mode

BITMAPINFOHEADER structure

  • 2018-04-18
Feedback

In this article

TheBITMAPINFOHEADER structure contains information about the dimensions and color format of a DIB.

Syntax

typedef struct tagBITMAPINFOHEADER {  DWORD biSize;  LONG  biWidth;  LONG  biHeight;  WORD  biPlanes;  WORD  biBitCount;  DWORD biCompression;  DWORD biSizeImage;  LONG  biXPelsPerMeter;  LONG  biYPelsPerMeter;  DWORD biClrUsed;  DWORD biClrImportant;} BITMAPINFOHEADER, *PBITMAPINFOHEADER;

Members

  • biSize
    The number of bytes required by the structure.

  • biWidth
    The width of the bitmap, in pixels.

    IfbiCompression is BI_JPEG or BI_PNG, thebiWidth member specifies the width of the decompressed JPEG or PNG image file, respectively.

  • biHeight
    The height of the bitmap, in pixels. IfbiHeight is positive, the bitmap is a bottom-up DIB and its origin is the lower-left corner. IfbiHeight is negative, the bitmap is a top-down DIB and its origin is the upper-left corner.

    IfbiHeight is negative, indicating a top-down DIB,biCompression must be either BI_RGB or BI_BITFIELDS. Top-down DIBs cannot be compressed.

    IfbiCompression is BI_JPEG or BI_PNG, thebiHeight member specifies the height of the decompressed JPEG or PNG image file, respectively.

  • biPlanes
    The number of planes for the target device. This value must be set to 1.

  • biBitCount
    The number of bits-per-pixel. ThebiBitCount member of theBITMAPINFOHEADER structure determines the number of bits that define each pixel and the maximum number of colors in the bitmap. This member must be one of the following values.

    ValueMeaning
    0The number of bits-per-pixel is specified or is implied by the JPEG or PNG format.
    1The bitmap is monochrome, and thebmiColors member ofBITMAPINFO contains two entries. Each bit in the bitmap array represents a pixel. If the bit is clear, the pixel is displayed with the color of the first entry in thebmiColors table; if the bit is set, the pixel has the color of the second entry in the table.
    4The bitmap has a maximum of 16 colors, and thebmiColors member ofBITMAPINFO contains up to 16 entries. Each pixel in the bitmap is represented by a 4-bit index into the color table. For example, if the first byte in the bitmap is 0x1F, the byte represents two pixels. The first pixel contains the color in the second table entry, and the second pixel contains the color in the sixteenth table entry.
    8The bitmap has a maximum of 256 colors, and thebmiColors member ofBITMAPINFO contains up to 256 entries. In this case, each byte in the array represents a single pixel.
    16The bitmap has a maximum of 2^16 colors. If thebiCompression member of theBITMAPINFOHEADER is BI_RGB, thebmiColors member ofBITMAPINFO isNULL. EachWORD in the bitmap array represents a single pixel. The relative intensities of red, green, and blue are represented with five bits for each color component. The value for blue is in the least significant five bits, followed by five bits each for green and red. The most significant bit is not used. ThebmiColors color table is used for optimizing colors used on palette-based devices, and must contain the number of entries specified by thebiClrUsed member of theBITMAPINFOHEADER.

    If thebiCompression member of theBITMAPINFOHEADER is BI_BITFIELDS, thebmiColors member contains threeDWORD color masks that specify the red, green, and blue components, respectively, of each pixel. EachWORD in the bitmap array represents a single pixel.

    When thebiCompression member is BI_BITFIELDS, bits set in eachDWORD mask must be contiguous and should not overlap the bits of another mask. All the bits in the pixel do not have to be used.

    24The bitmap has a maximum of 2^24 colors, and thebmiColors member ofBITMAPINFO isNULL. Each 3-byte triplet in the bitmap array represents the relative intensities of blue, green, and red, respectively, for a pixel. ThebmiColors color table is used for optimizing colors used on palette-based devices, and must contain the number of entries specified by thebiClrUsed member of theBITMAPINFOHEADER.
    32The bitmap has a maximum of 2^32 colors. If thebiCompression member of theBITMAPINFOHEADER is BI_RGB, thebmiColors member ofBITMAPINFO isNULL. EachDWORD in the bitmap array represents the relative intensities of blue, green, and red for a pixel. The value for blue is in the least significant 8 bits, followed by 8 bits each for green and red. The high byte in eachDWORD is not used. ThebmiColors color table is used for optimizing colors used on palette-based devices, and must contain the number of entries specified by thebiClrUsed member of theBITMAPINFOHEADER.

    If thebiCompression member of theBITMAPINFOHEADER is BI_BITFIELDS, thebmiColors member contains threeDWORD color masks that specify the red, green, and blue components, respectively, of each pixel. EachDWORD in the bitmap array represents a single pixel.

    When thebiCompression member is BI_BITFIELDS, bits set in eachDWORD mask must be contiguous and should not overlap the bits of another mask. All the bits in the pixel do not need to be used.

     

  • biCompression
    The type of compression for a compressed bottom-up bitmap (top-down DIBs cannot be compressed). This member can be one of the following values.

    ValueDescription
    BI_RGBAn uncompressed format.
    BI_RLE8A run-length encoded (RLE) format for bitmaps with 8 bpp. The compression format is a 2-byte format consisting of a count byte followed by a byte containing a color index. For more information, seeBitmap Compression.
    BI_RLE4An RLE format for bitmaps with 4 bpp. The compression format is a 2-byte format consisting of a count byte followed by two word-length color indexes. For more information, seeBitmap Compression.
    BI_BITFIELDSSpecifies that the bitmap is not compressed and that the color table consists of threeDWORD color masks that specify the red, green, and blue components, respectively, of each pixel. This is valid when used with 16- and 32-bpp bitmaps.
    BI_JPEGIndicates that the image is a JPEG image.
    BI_PNGIndicates that the image is a PNG image.

     

  • biSizeImage
    The size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps.

    IfbiCompression is BI_JPEG or BI_PNG,biSizeImage indicates the size of the JPEG or PNG image buffer, respectively.

  • biXPelsPerMeter
    The horizontal resolution, in pixels-per-meter, of the target device for the bitmap. An application can use this value to select a bitmap from a resource group that best matches the characteristics of the current device.

  • biYPelsPerMeter
    The vertical resolution, in pixels-per-meter, of the target device for the bitmap.

  • biClrUsed
    The number of color indexes in the color table that are actually used by the bitmap. If this value is zero, the bitmap uses the maximum number of colors corresponding to the value of thebiBitCount member for the compression mode specified bybiCompression.

    IfbiClrUsed is nonzero and thebiBitCount member is less than 16, thebiClrUsed member specifies the actual number of colors the graphics engine or device driver accesses. IfbiBitCount is 16 or greater, thebiClrUsed member specifies the size of the color table used to optimize performance of the system color palettes. IfbiBitCount equals 16 or 32, the optimal color palette starts immediately following the threeDWORD masks.

    When the bitmap array immediately follows theBITMAPINFO structure, it is a packed bitmap. Packed bitmaps are referenced by a single pointer. Packed bitmaps require that thebiClrUsed member must be either zero or the actual size of the color table.

  • biClrImportant
    The number of color indexes that are required for displaying the bitmap. If this value is zero, all colors are required.

Remarks

TheBITMAPINFO structure combines theBITMAPINFOHEADER structure and a color table to provide a complete definition of the dimensions and colors of a DIB. For more information about DIBs, seeDevice-Independent Bitmaps andBITMAPINFO.

An application should use the information stored in thebiSize member to locate the color table in aBITMAPINFO structure, as follows:

pColor = ((LPSTR)pBitmapInfo + (WORD)(pBitmapInfo->bmiHeader.biSize));

TheBITMAPINFOHEADER structure is extended to allow a JPEG or PNG image to be passed as the source image toStretchDIBits.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Wingdi.h (include Windows.h)

See also

Bitmaps Overview

Bitmap Structures

BITMAPINFO

BITMAPV4HEADER

BITMAPV5HEADER

CreateDIBitmap

StretchDIBits

In this article