MFC CBitmap::CreateBitmap()

本文详细介绍了CBitmap类的CreateBitmap函数,用于初始化具有指定宽度、高度和位模式的设备相关内存位图。参数包括位图的尺寸、颜色平面数和颜色位数。当不再需要位图时,应先从设备上下文中移除,再删除CBitmap对象。位图可通过CDC::SelectObject选入内存设备上下文,并使用CDC::BitBlt进行复制。
摘要由CSDN通过智能技术生成

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

nWidthSpecifies the width (in pixels) of the bitmap.
【指定位图的宽度(以像素为单位)。】
nHeightSpecifies the height (in pixels) of the bitmap.
【指定位图的高度(以像素为单位)。】
nPlanesSpecifies the number of color planes in the bitmap.
【指定位图中颜色平面的数目。】
nBitcountSpecifies the number of color bits per display pixel.
【指定每个显示像素的颜色位数。】
lpBitsPoints 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成员函数下描述。】

心得体会

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值