Win GDI 函数 CreateDIBDC 在 x64 平台上无法正常工作

发布于 2024-10-20 23:53:31 字数 731 浏览 6 评论 0原文

我有一个要移植到 x64 平台的静态 win32 dll 代码..有许多函数正在使用 Windows GDI 函数,如 CreateDIBDC、CreatePen 等......

问题是在 x86 上处理 DLL 的函数时,我在使用 Windows API 时从未遇到过任何问题。但是在将代码移植到 x64 时,Windows API 产生了问题....

dll 的功能基本上处理位图图像的图像处理。从而利用windows的bitmapinfoheader、bitmap等结构...

请帮忙,因为它很紧急。

--------补充

WindowVar = GetActiveWindow();
DisplayDeviceContext = GetDC(WindowVar);
BitmapVar = CreateDIBSection (DisplayDeviceContext, BITMAPINFOheaderstructure,
    COLORmap, &lpvBits, 0, 0L);
//copy data to the BitmapVar from image
byteswritten = GetObject(BitmapVar, sizeof(DIBSECTION), &DibSectionvar);

,但主要问题是,在 x86 上工作时,GetObject 函数 GetObject 给出的字节数为 84,这是正确的,但在 x64 上它只给出 32。但是这必须是 92...

I have a static win32 dll code that is to be ported to x64 platform.. there are many functions that are using Windows GDI functions like CreateDIBDC, CreatePen, etc....

The problem is that while processing the functions of the DLL on x86, I have never faced any problem using the Windows APIs. But while porting the code to x64, the windows APIs are creating problems....

The functions of the dll basically deal with image processing on Bitmap images. thus making use of bitmapinfoheader, bitmap, etc structures of windows...

please help as it is urgent.

-------addition

WindowVar = GetActiveWindow();
DisplayDeviceContext = GetDC(WindowVar);
BitmapVar = CreateDIBSection (DisplayDeviceContext, BITMAPINFOheaderstructure,
    COLORmap, &lpvBits, 0, 0L);
//copy data to the BitmapVar from image
byteswritten = GetObject(BitmapVar, sizeof(DIBSECTION), &DibSectionvar);

but the main problem is that while working on x86, the GetObject function GetObject gives byteswritten as 84, which is correct but on x64 it gives only 32. however this must be 92...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

逐鹿 2024-10-27 23:53:31

无论如何我得到了答案。这是一个奇怪的问题。 DIBSECTION 结构的大小不正确。所以最后我将 sizeof(DIBSECTION) 传递给一个变量并将其作为函数的输入传递。不知道为什么,但它解决了问题。

I got the answer anyhow. It was a wierd problem. The size of DIBSECTION structure was not coming out to be right. so finally i took sizeof(DIBSECTION) to a variable and passed it as input to the function. dont know why but it solved the problem.

不弃不离 2024-10-27 23:53:31

无论如何,我在 x64 上也遇到了同样的问题。

以下调用返回的大小不同,test = 28test2 = 32

需要将大小四舍五入到 4 字节边界。对于 32 位似乎不重要,但对于 x64 则重要

int test = sizeof(BITMAP);
int test2 = GetObject(hExportBitmap, sizeof(BITMAP), NULL);

For what it's worth I have had the same problem with x64 .

The sizes returned by the following calls are different , test = 28, test2 = 32.

Need to round up size to a 4 byte boundary . Doesn't seem to matter with 32 bit but does with x64

int test = sizeof(BITMAP);
int test2 = GetObject(hExportBitmap, sizeof(BITMAP), NULL);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文