BITMAPINFO结构体的一个疑问
今天编一个显示位图的程序,使用了StretchDIBits函数,它的倒数第二个参数是BITMAPINFO结构体指针。BITMAPINFO结构体是这样定义的:
它的第一个参数是位图信息头,第二个参数让我很难理解。我查了下MSDN,它这样解释的:
The BITMAPINFO structure defines the dimensions and color information for a DIB.
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO, *PBITMAPINFO;
Members
bmiHeader
Specifies a BITMAPINFOHEADER structure that contains information about the dimensions of color format.
.
bmiColors
The bmiColors member contains one of the following:
An array of RGBQUAD. The elements of the array that make up the color table.
An array of 16-bit unsigned integers that specifies indexes into the currently realized logical palette. This use of bmiColors is allowed for functions that use DIBs. When bmiColors elements contain indexes to a realized logical palette, they must also call the following bitmap functions:
CreateDIBitmap
CreateDIBPatternBrush
CreateDIBSection
The iUsage parameter of CreateDIBSection must be set to DIB_PAL_COLORS.
The number of entries in the array depends on the values of the biBitCount and biClrUsed members of the BITMAPINFOHEADER structure.
The colors in the bmiColors table appear in order of importance. For more information, see the Remarks section.
Remarks
A DIB consists of two distinct parts: a BITMAPINFO structure describing the dimensions and colors of the bitmap, and an array of bytes defining the pixels of the bitmap. The bits in the array are packed together, but each scan line must be padded with zeroes to end on a LONG data-type boundary. If the height of the bitmap is positive, the bitmap is a bottom-up DIB and its origin is the lower-left corner. If the height is negative, the bitmap is a top-down DIB and its origin is the upper left corner.
A bitmap is packed when the bitmap array immediately follows the BITMAPINFO header. Packed bitmaps are referenced by a single pointer. For packed bitmaps, the biClrUsed member must be set to an even number when using the DIB_PAL_COLORS mode so that the DIB bitmap array starts on a DWORD boundary.
Note The bmiColors member should not contain palette indexes if the bitmap is to be stored in a file or transferred to another application.
Unless the application has exclusive use and control of the bitmap, the bitmap color table should contain explicit RGB values.
我看了半天,也没明白bmiColors[1]有什么用。我唯一明确的一点是bmiColors[1]所包含的信息并没有存在位图文件,在传输图像时也不需要传输。
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO, FAR *LPBITMAPINFO, *PBITMAPINFO;
它的第一个参数是位图信息头,第二个参数让我很难理解。我查了下MSDN,它这样解释的:
The BITMAPINFO structure defines the dimensions and color information for a DIB.
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO, *PBITMAPINFO;
Members
bmiHeader
Specifies a BITMAPINFOHEADER structure that contains information about the dimensions of color format.
.
bmiColors
The bmiColors member contains one of the following:
An array of RGBQUAD. The elements of the array that make up the color table.
An array of 16-bit unsigned integers that specifies indexes into the currently realized logical palette. This use of bmiColors is allowed for functions that use DIBs. When bmiColors elements contain indexes to a realized logical palette, they must also call the following bitmap functions:
CreateDIBitmap
CreateDIBPatternBrush
CreateDIBSection
The iUsage parameter of CreateDIBSection must be set to DIB_PAL_COLORS.
The number of entries in the array depends on the values of the biBitCount and biClrUsed members of the BITMAPINFOHEADER structure.
The colors in the bmiColors table appear in order of importance. For more information, see the Remarks section.
Remarks
A DIB consists of two distinct parts: a BITMAPINFO structure describing the dimensions and colors of the bitmap, and an array of bytes defining the pixels of the bitmap. The bits in the array are packed together, but each scan line must be padded with zeroes to end on a LONG data-type boundary. If the height of the bitmap is positive, the bitmap is a bottom-up DIB and its origin is the lower-left corner. If the height is negative, the bitmap is a top-down DIB and its origin is the upper left corner.
A bitmap is packed when the bitmap array immediately follows the BITMAPINFO header. Packed bitmaps are referenced by a single pointer. For packed bitmaps, the biClrUsed member must be set to an even number when using the DIB_PAL_COLORS mode so that the DIB bitmap array starts on a DWORD boundary.
Note The bmiColors member should not contain palette indexes if the bitmap is to be stored in a file or transferred to another application.
Unless the application has exclusive use and control of the bitmap, the bitmap color table should contain explicit RGB values.
我看了半天,也没明白bmiColors[1]有什么用。我唯一明确的一点是bmiColors[1]所包含的信息并没有存在位图文件,在传输图像时也不需要传输。
...全文
相关推荐
BitMapInfo.rar_BITMAPINFO_bitmap_情报
除了BITMAPINFOHEADER,BITMAPINFO结构体还包括了一个RGBQUAD数组,即颜色表。对于索引色彩模式(如8位位图),颜色表定义了256种颜色的红、绿、蓝分量。
BitmapInfo.rar_bitmap linux
BitmapInfo.h是头文件,通常在这个文件里,我们会看到BitmapInfo结构体或者类的定义,这个结构体或类会详细描述一个位图的所有属性。
WIN32 API结构体详解
- BITMAPINFO:位图信息结构体,包含了位图的颜色格式、大小等详细信息。 - RECT:矩形结构体,用于表示屏幕或窗口上的矩形区域。
C# FFmpeg.rar
本文介绍了BITMAPINFO结构体的定义及其内存布局,以及BITMAPINFOHEADER结构体的字段和封送方式。同时,阐述了FFmpegBinariesHelper类如何在不同操作系统上注册FFm
一个对DIB操作的例子
在“一个对DIB操作的例子”中,我们可以预见到代码可能会涉及到以下几个步骤:1. **定义DIB结构**:首先,我们需要创建一个BITMAPINFO结构体,填充必要的信息,如位图的尺寸、颜色位深等。


图形处理/算法
