CreateCompatibleBitmap failing

CreateCompatibleBitmap failing
Wednesday, July 26, 2006 8:17 PMSimonRevSays 
0Sign In to VoteOn a test Windows XP machine with 5 monitors (Overall desktop bounding box is 3328x2048), I create a bitmap that will span the entire display. 

Normally this works fine.  However, if several applications are open (in particular multiple instances of IE7 on certain web sites), the call to CreateCompatibleBitmap(hdc, 3328, 2048) fails and returns NULL.  GetLastError in this case returns 0 (NoError).

Is there a limit to the total amount of bitmap space that the system can allocate?  Is it normal for CreateCompatibleBitmap to fail with no error code?  Anyone have any ideas on how to work around this, or is there a system setting that can allow more memory to be dedicated to bitmaps?

ReplyQuote
Answers
Wednesday, July 26, 2006 8:23 PMkuphryn 
0Sign In to VoteInteresting.  sometimes yes sometimes no

possible os resources

check out CreateDIBSection()

Kuphryn

ReplyQuote
All Replies
Wednesday, July 26, 2006 8:23 PMkuphryn 
0Sign In to VoteInteresting.  sometimes yes sometimes no

possible os resources

check out CreateDIBSection()

Kuphryn

ReplyQuote
Thursday, July 27, 2006 11:12 AMnobugzMVP, Moderator
0Sign In to Vote3328 x 2048 x 3 bytes = 20 MB.  That's hefty but not impossible.  Maybe your running out of swap file space?

ReplyQuote
Thursday, July 27, 2006 2:05 PMSimonRevSays 
0Sign In to VoteI don't think so.  I have 1GB RAM and 1.5 GB swap.  The system is reporting 400+ MB of physical memory as free.  Also, aside from the CreateCompatibleBitmap issues, I am not receiving any other memory allocation errors.
ReplyQuote
Thursday, July 27, 2006 2:26 PMeinarosModerator
0Sign In to VoteWhat happens if you, upon failing to create the large bitmap, try smaller sizes?
ReplyQuote
Thursday, July 27, 2006 2:56 PMSimonRevSays 
0Sign In to VoteModified my code so that in the failure case it tried to create progressively smaller and smaller images.  It succeeds after several iterations at 2728, 1448.

Also, rechecked my call to GetLastError.  It is really returning 8 (ERROR_NOT_ENOUGH_MEMORY) which makes more sense.  I am going to explore the DIBSection stuff a bit more as, in this case, I am converting the thing to a device independent bitmap at a later time anyway. 

It still seems odd that I should be getting out of memory errors with so much free RAM (not to mention swap).  I would be interested if anyone has any thoughts on that.

ReplyQuote
Thursday, July 27, 2006 7:54 PMSimonRevSays 
0Sign In to VoteI was able to get satisfactory results with CreateDIBSection.  I will need to tweak my code for performance a little bit but this should work.

I guess that Windows must have some sort of undocumented restriction on the amount of device dependent bitmap memory it will allocate.  Perhaps it is linked to video RAM, although that would be odd as I have 3 video cards and this bitmap streches across all monitors, so storing it in any one video card would be an odd choice.  Anyway, thanks for all your help.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值