- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将存储在我的文件中的位图加载到我的应用程序中。我通过以下方式进行
HBITMAP hbitmap = NULL;
hbitmap = (HBITMAP)LoadImage(NULL,TEXT("F:\\Microsoft Visual Studio 2010 Projects\\test\\test\\bitmap1.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
BITMAP bmp;
GetObject(hbitmap,sizeof(BITMAP),&bmp);
在位图结构中,位图大小正确如下:
bmp {bmType=0 bmWidth=1920 bmHeight=1080 ...} tagBITMAP
bmType 0 long
bmWidth 1920 long
bmHeight 1080 long
bmWidthBytes 7680 long
bmPlanes 1 unsigned short
bmBitsPixel 32 unsigned short
bmBits 0x00000000 void *
问题是指向位图的指针 bmBits 总是指向 NULL (0x00000000)。谁能告诉我如何解决这个问题?非常感谢!
最佳答案
这是记录在案的行为。来自 GetObject() 的 MSDN 文章:
If hgdiobj is a handle to a bitmap created by any other means, GetObject returns only the width, height, and color format information of the bitmap. You can obtain the bitmap's bit values by calling the GetDIBits or GetBitmapBits function.
关于c++ - 使用 LoadImage() 中的 GetObjet() 后,BITMAP 结构中的 bmBit 始终为 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19276590/
上下文:我正在尝试截取另一个窗口的屏幕截图以将其输入 OpenCV。我在网上找到了一些代码,应该能够将 BITMAP 转换为 OpenCV 可以使用的东西。不幸的是我遇到了一些麻烦。 问题:为什么 b
我正尝试按照这篇文章中的说明将像素数组转换为 HBITMAP:How to convert an Array of pixels to HBITMAP . 基本上,数组被转换为HBITMAP,然后通过
我正在尝试将存储在我的文件中的位图加载到我的应用程序中。我通过以下方式进行 HBITMAP hbitmap = NULL; hbitmap = (HBITMAP)LoadImage(NULL,TEXT
我是一名优秀的程序员,十分优秀!