gpt4 book ai didi

c++ - 使用 LoadImage() 中的 GetObjet() 后,BITMAP 结构中的 bmBit 始终为 NULL

转载 作者:行者123 更新时间:2023-11-30 02:52:03 24 4
gpt4 key购买 nike

我正在尝试将存储在我的文件中的位图加载到我的应用程序中。我通过以下方式进行

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com