Link to home
Start Free TrialLog in
Avatar of nietod
nietod

asked on

DDB VS. DIB Questions

This is not a question about the difference between DDBs and DIBs.  So don't explan that.

What I am asking about is there use.  I was under the impression that DIBs were used for permanent storage and that a program must load them and convert them to DDBs for use with a particular DC.

However I read some microsoft documentation that said that DDBs are just for compatibility with old applications and the newer applications should only use DIBs.  

Is that true?  

If so, can a DIB be selected into a DC just like a DDB?  
Given arrays of color and pixel information how do I create a DIB and get a handle to it?  The functions I've found seem to create DDBs.

If I need to repeatidly display a DIB image, it is best to convert it to a DDB and display that repeatidly?
ASKER CERTIFIED SOLUTION
Avatar of galkin
galkin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nietod
nietod

ASKER

I appreciate your comments.  They were helpful, but they still left an important question unanswered.

I still need to know how do you work with a DIB.  It sounds like you allocate and define it in your programs  memory so you don't have a handle to it like you do for a DDB.  I assume that means it does not get selected into a device context.  So how do you use it?  For example, how do you draw it and how can you draw to it?
I allocate memory using GlobalAlloc which return handle to global memory block of type HANDLE which can be considered as DIB handle. Actually DIB doesn't have have true handle like DDB since all function that operate with DIB operate with raw data( DIB bits) and DIB desription which is BITMAPINFOHEADER structure explaining how to treat this raw data. You cannot "draw" onto DIB as I am sorry for repeating it is raw data so you can change it by changing raw data. This is memory block so apply the same methods you would apply to change values of memory block. These is no analogy with DDB's selecting into memory DC and drawing on it and then blitting onto actual DC. To draw various shapes and lines "on DIB" you must directly change values of corresponding bits. There are to functions SetDIBitsToDevice and StretchDIBits which set DIB, i.e. raw data(BITMAPINFOHEADER followed by bits themselves) to target DC.
Avatar of nietod

ASKER

thanks,  

I'll try fooling with this tommorrow.