开发者

Win GDI function CreateDIBDC not working properly for x64 platform

开发者 https://www.devze.com 2023-02-15 07:33 出处:网络
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....

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...


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.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消