CBitmap::CreateBitmap
Initializes a device-dependent memory bitmap that has the specified width, height, and bit pattern.
【初始化具有指定宽度、高度和位模式的设备相关内存位图。】
Syntax
BOOL CreateBitmap(
int nWidth,
int nHeight,
UINT nPlanes,
UINT nBitcount,
const void* lpBits
);
Parameters
| nWidth | Specifies the width (in pixels) of the bitmap. 【指定位图的宽度(以像素为单位)。】 |
| nHeight | Specifies the height (in pixels) of the bitmap. 【指定位图的高度(以像素为单位)。】 |
| nPlanes | Specifies the number of color planes in the bitmap. 【指定位图中颜色平面的数目。】 |
| nBitcount | Specifies the number of color bits per display pixel. 【指定每个显示像素的颜色位数。】 |
| lpBits | Points to a short-integer array that contains the initial bitmap bit values. If it is NULL, the new bitmap is left uninitialized. 【指向包含初始位图位值的短整数数组。如果为空,则新位图未初始化。】 |
Return Value
Nonzero if successful; otherwise 0.
【如果成功,则为非零;否则为0。】
Remarks
For a color bitmap, either the nPlanes or nBitcount parameter should be set to 1. If both of these parameters are set to 1, CreateBitmap creates a monochrome bitmap.
【对于彩色位图,nPlanes或nBitcount参数应设置为1。如果这两个参数都设置为1,CreateBitmap将创建单色位图。】
Although a bitmap cannot be directly selected for a display device, it can be selected as the current bitmap for a “memory device context” by using CDC::SelectObject and copied to any compatible device context by using the CDC::BitBlt function.
【尽管不能直接为显示设备选择位图,但可以使用CDC::SelectObject将其选作“内存设备上下文”的当前位图,并使用CDC::BitBlt函数将其复制到任何兼容的设备上下文。】
When you finish with the CBitmap object created by the CreateBitmap function, first select the bitmap out of the device context, then delete the CBitmap object.
【用完CreateBitmap函数创建的CBitmap对象后,首先从设备上下文中选择位图,然后删除CBitmap对象。】
For more information, see the description of the bmBits field in the BITMAP structure. The BITMAP structure is described under the CBitmap::CreateBitmapIndirect member function.
【有关详细信息,请参阅位图结构中bmBits字段的说明。位图结构在CBitmap::CreateBitmapIndirect成员函数下描述。】
本文详细介绍了CBitmap类的CreateBitmap函数,用于初始化具有指定宽度、高度和位模式的设备相关内存位图。参数包括位图的尺寸、颜色平面数和颜色位数。当不再需要位图时,应先从设备上下文中移除,再删除CBitmap对象。位图可通过CDC::SelectObject选入内存设备上下文,并使用CDC::BitBlt进行复制。
683

被折叠的 条评论
为什么被折叠?



