I want to create a bitmap (to use as a buffer) that is X pixels wide and Y pixels high. The bitmap itself won't ever be displayed, saved, or loaded with a bitmap from disk. It will simply act as a buffer that will hold an image that can be displayed in a canvas of another component.
Most likely, it will be 256 colors. I will need to set at least 16 (maybe 32) of the colors in the palette for this bitmap myself...the remaining colors will probably not be used.
Throughout the program, I will be writing to this "bitmap" directly, and then blitting it to a canvas in order to display it.
What I want to know is four things:
1. What exactly do I need to do to set up this bitmap? Does this entail a call to CreateDIBSection, or is there a better way to do it? I would like code that demonstrates this.
2. I need to know how to write to the bitmap efficiently...depending on what was done in step #1, I don't know if this would require SetDIBits, or what...
3. I need to know how to copy the data in the bitmap to a canvas directly and quickly. I suppose that I would use BitBlt, but perhaps there is a better way.
4. I need to know how to deallocate the bitmap and everything associated with it.
The bitmap is going to be a private member of a component. When required, the bitmap will be copied to the canvas of that same component. The bitmap may be allocated and deallocated several times in the "life" of the object...for instance, when the component is resized, the bitmap will need to be resized as well. The bitmap will be created when the object is created, and destroyed when the object is destroyed, but may be destroyed and recreated many times during the lifetime of the component.
What I am asking for is some code to specifically meet my four needs shown above. Speed is very important. I am not all that familiar with the Windows API and GDI, so any additional comments will help. If you need any more info, please ask.
Thanks in advance.