本文主要是介绍MFC CBitmap::CreateBitmap(),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
CBitmap::CreateBitmap
- Syntax
- Parameters
- Return Value
- Remarks
- 心得体会
Initializes a device-dependent memory bitmap that has the specified width, height, and bit pattern.
【初始化具有指定宽度、高度和位模式的设备相关内存位图。】
回到 CBitmap Class
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成员函数下描述。】
心得体会
这篇关于MFC CBitmap::CreateBitmap()的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!