Ways Around GDI Resource Limits?
Hello All,
I have created some pretty graphic intensive controls.. They all use CBitmap for holding their
images..I am having a problem with this because
it eats up the GDI resources.. Heres my question/s
a. Is there a way to store a Bitmap(in memory) that I can draw to the screen that does not take up GDI resources..
b. Is there any way to expand the available GDI resources in Windows95/98?
Thanks for any help!
Regards
David Swigger
Please don't tell me it's impossible. That just means I have to proove it...
Re: Ways Around GDI Resource Limits?
To solve the resources leaking, you should delete the GDI object after you finish to used it. Take a look to
CGdiObject::DeleteObject()
or
BOOL DeleteObject(
HGDIOBJ hObject // handle to graphic object
);
Good luck
Fabian
Re: Ways Around GDI Resource Limits?
There are two ways to approach this problem.
The easiest way, is to NOT keep all of your CBitmaps in memory. Dispose of them after they have been drawn, reload them as neccessary. You can reduce any performace loss by creating a type of caching mechanism to keep frequently drawn CBitmaps in memory.
The harder method would be to NOT use CBitmaps at all, instead using DIB's. Using DIB's will not use GDI, since a DIB is using memory from HEAP. With DIB's you will be responsible for making sure that the DIB color depth is less than or equal to the screen's color depth (for Blting performace) as well as color mapping performance issues. (Read Nigel Thompson's book on Animation Techniques in Win32 (MSPRESS)). Be sure to read up on 'identity palettes' to make sure your 256 color mode performance is optimal.
The first technique is a quicker fix, but if done right the second method is much better.
Regards,
Todd