Jump to content

How can I create >2GB DIB Section on 64-bit Windows


Recommended Posts

I want to use CreateDIBSection to create a DIB section of >2GB, and I prefer to use GDI functions, not GDI+ or .Net.

I know I can not accomplish this task on 32-bit Windows, so I tried on 64-bit version. Then I found that I can create several 2GB DIB sections but can not create one which is over 2GB, even if a few bigger than 2GB is impossible (such as 2.1GB). The test platform is 64-bit Windows 7 with 8GB physical memory.

It seems that there's a 2GB limitaion, is that true? Does GDI object still have this 2GB limitation on 64-bit OS?

But I can allocate one memory block much more than 2GB on the same system using malloc or some functions like that.

I need your help, thank you.

Link to comment
Share on other sites

I don't know. I suppose you'd have to use VirtualAlloc, at which point it's not a DIB section.

Anyway, this isn't a programming help forum. I really don't have an answer for you, just the one guess.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

I don't know. I suppose you'd have to use VirtualAlloc, at which point it's not a DIB section.

Anyway, this isn't a programming help forum. I really don't have an answer for you, just the one guess.

Thank you very much for your reply.

Yes, I know that this forum is just about Paint.Net, and I have found a topic which may be the same as mine:

but I can not find any solution in that post except that he finally can handle large images over 2GB after your tips (you said: I use either CreateDIBSection() or VirtualAlloc() to allocate the memory), and I'm using CreateDIBSection, too, but still have this 2GB limitation.

I've installed Paint.Net of version 3.5.8, and found that I can use it to create an image of 20000*28000 which is over 2GB, then I have an idea to post the quesion here.

Link to comment
Share on other sites

Thank you very much for your reply.

Yes, I know that this forum is just about Paint.Net, and I have found a topic which may be the same as mine: http://forums.getpai...-2gb-of-memory/

but I can not find any solution in that post except that he finally can handle large images over 2GB after your tips (you said: I use either CreateDIBSection() or VirtualAlloc() to allocate the memory), and I'm using CreateDIBSection, too, but still have this 2GB limitation.

I've installed Paint.Net of version 3.5.8, and found that I can use it to create an image of 20000*28000 which is over 2GB, then I have an idea to post the quesion here.

hi eslwang,

I don't use DIB section. As Rick says, you can use VirtualAlloc and pass the pointer to this BitMap constructor and it will be fine. However, as I said in the other topic, I can use this VirtualAlloc + Btmap combo to allocate it on RAM, but I can't save it to disk (the Bitmap.Save method crashes for >4GB, but I don't remember if 2GB is the limit). So I use the OpenCV lib now (with binds to C#). But if you don't need to save it to the disk, the VirtualAlloc + Bitmap combo will work just fine for >2GB.

EDIT: yes, .Net has this 2GB limitation, even for 64bits system. VirtualAlloc is the usual way to overcome this issue. It's still part of Windows API, it's just that .Net don't have any class with direct access to it, so you need this importdll stuff. I hope that with this new WinRT on Windows 8, this 2GB limit will be treated properly.

Edited by laobrasuca
Link to comment
Share on other sites

hi eslwang,

I don't use DIB section. As Rick says, you can use VirtualAlloc and pass the pointer to this BitMap constructor and it will be fine. However, as I said in the other topic, I can use this VirtualAlloc + Btmap combo to allocate it on RAM, but I can't save it to disk (the Bitmap.Save method crashes for >4GB, but I don't remember if 2GB is the limit). So I use the OpenCV lib now (with binds to C#). But if you don't need to save it to the disk, the VirtualAlloc + Bitmap combo will work just fine for >2GB.

EDIT: yes, .Net has this 2GB limitation, even for 64bits system. VirtualAlloc is the usual way to overcome this issue. It's still part of Windows API, it's just that .Net don't have any class with direct access to it, so you need this importdll stuff. I hope that with this new WinRT on Windows 8, this 2GB limit will be treated properly.

Hi Leo, thank you again, the other is in Messages :)

You teach me fishing, not just give me the fish. I'll try your method and keep in touch.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...