Solved

cannot create 4096x3072 bitmap!!

Posted on 2000-04-05
8
240 Views
Last Modified: 2013-11-20
I have these code:
void CMyClass ::CreateBitmap()
{
     CDC * pDC = GetDC();
    CBitmap bmp;
    bmp.CreateCompatibleBitmap(pDC,4096,3072);
    ReleaseDC(pDC)
}
but the CreateCompatibleBitmap() return 0, that means the bmp cannot be created. Why?? what's wrong with the code.  Any idea??
0
Comment
Question by:eugeneng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 2687032
Hi eugeneng,

check return value of GetLastError() when creation failed.

I guess you'll get an last error 8, which occurs if to less memory is available for an operation. A bitmap of 4096pixel x 3072pixel x 32bit/pixel will need about a 48MB block of continuous free memory.

On my machine the code works, I have 256MB of RAM...

ZOPPO
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2688422
btw .. I assume in your real code you actually do something with the bmp .. the code you have just creates the bitmap and then it gets destroyed when bmp goes out of scope.

Perhaps you can change you code so it uses an array of smaller bitmaps?

ceratinly a bitmap of the size your are requesting is pretty goddamn big :-)
0
 

Expert Comment

by:leowlf
ID: 2690121
hi RONSLOW,

how does using an array of smaller bmp solves the problem? shouldn't they use up the same amount of memory?
 
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:RONSLOW
ID: 2690210
the problem isn't so much the total amount of memory, it is that it is one big contiguous block.

lots of smaller blicks can be allocate more easily than one big one.
0
 

Author Comment

by:eugeneng
ID: 2691991
First of all, I don't have much of other code beside the example above. Then, do you guy notice that, 4096x3072 is actually (1024*4)x(768*4). I'm using 17inc monitor, and my program has a zoom function, which will provide zooming out to 25% of the original picture, therefore I have to create such a goddamn big bitmap.
   But if I use array of bitmap, I still need same amount of memory as the big one right ? eventhought lots of smaller blocks can be allocated more easily that the big one, but I STILL NEED that much of memory right ?
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 50 total points
ID: 2692019
In smaller blocks the OS will dynamically swap them in and out of RAM (ie virtual memory).  One big block won't do it.

Also, you only need a bitmap as big as your screen resolution.  Even if you zoom, you just regenerate the image at that resolution .. not point in having a big bitmap that you can only ever see 1/16th of.
0
 

Expert Comment

by:leowlf
ID: 2692143
eugeneng,

just for curiosity, do u need to do image processing on that image, such as mosaic, edge enhangement, etc?

... just wondering if it is possible to image process the whole image that has been splitted into an array of image.
0
 

Author Comment

by:eugeneng
ID: 2692333
The reason I want to use 4 times of screen size for zooming is I don't to redraw my image everytime user changes the zoom setting, because that will take time. Instead, all I want to do is just use StrectBlt() to re-blit the image.

to  leowlf,
no, I do any other process to the image, in fact, I draw everything on a temporary memory DC, and blit the memDC to the screen DC.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 55
Separate files macro - Errors on larger data set 18 73
maven archtype selection in eclipse 1 58
Not needed 13 129
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question