win32 CreateDIBitmap ---- 根据 DIB文件 创建 Bitmap

The CreateDIBitmap function creates a compatible bitmap (DDB) from a DIB and, optionally, sets the bitmap bits.

HBITMAP CreateDIBitmap(
  __in  HDC hdc,
  __in  const BITMAPINFOHEADER *lpbmih,
  __in  DWORD fdwInit,
  __in  const VOID *lpbInit,
  __in  const BITMAPINFO *lpbmi,
  __in  UINT fuUsage
);

Parameters

hdc [in]
A handle to a device context.

lpbmih [in]
A pointer to a bitmap information header structure, which may be one of those shown in the following table. For more information, see BITMAPV5HEADER.

If fdwInit is CBM_INIT, the function uses the bitmap information header structure to obtain the desired width and height of the bitmap as well as other information. Note that a positive value for the height indicates a bottom-up DIB while a negative value for the height indicates a top-down DIB. Calling CreateDIBitmap with fdwInit as CBM_INIT is equivalent to calling the CreateCompatibleBitmap function to create a DDB in the format of the device and then calling the SetDIBits function to translate the DIB bits to the DDB.

fdwInit [in]
Specifies how the system initializes the bitmap bits. The following value is defined.

ValueMeaning
CBM_INITIf this flag is set, the system uses the data pointed to by the lpbInit and lpbmi parameters to initialize the bitmap bits.If this flag is clear, the data pointed to by those parameters is not used.

If fdwInit is zero, the system does not initialize the bitmap bits.

lpbInit [in]
A pointer to an array of bytes containing the initial bitmap data. The format of the data depends on the biBitCount member of the BITMAPINFO structure to which the lpbmi parameter points.

lpbmi [in]
A pointer to a BITMAPINFO structure that describes the dimensions and color format of the array pointed to by the lpbInit parameter.

fuUsage [in]
Specifies whether the bmiColors member of the BITMAPINFO structure was initialized and, if so, whether bmiColors contains explicit red, green, blue (RGB) values or palette indexes. The fuUsage parameter must be one of the following values.

ValueMeaning
DIB_PAL_COLORSA color table is provided and consists of an array of 16-bit indexes into the logical palette of the device context into which the bitmap is to be selected.
DIB_RGB_COLORSA color table is provided and contains literal RGB values.

Return Value

If the function succeeds, the return value is a handle to the compatible bitmap.

If the function fails, the return value is NULL.

Remarks

The DDB that is created will be whatever bit depth your reference DC is. To create a bitmap that is of different bit depth, use CreateDIBSection.

For a device to reach optimal bitmap-drawing speed, specify fdwInit as CBM_INIT. Then, use the same color depth DIB as the video mode. When the video is running 4- or 8-bpp, use DIB_PAL_COLORS.

The CBM_CREATDIB flag for the fdwInit parameter is no longer supported.

When you no longer need the bitmap, call the DeleteObject function to delete it.

ICM: No color management is performed. The contents of the resulting bitmap are not color matched after the bitmap has been created.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值