This is an advanced DDB/DIB Section drawing question...
I have an application that uses 3 memory DC's to draw various layers of a final screen presentation in memory. The multiple mem DCs are for best efficiency, since some layers change quite often and others do not. Those that do not change very often tend to take quite a lot of time to draw and therefore I create 3 levels of mem DCs... if something has only changed on level 2, I just blt level 1 to 2 and then draw 2 and 3. If something changed on level 3 I just blt level 2 to 3 and draw 3. Much faster than redrawing all levels each time.
Another important fact is that I use a 256 color logical palette... my app only needs 256 colors and 8 bits per pixel... and has no need for 16/24/32 bit graphics.
Now... here's my question... I am trying to figire out which of the two following methods is more efficient.
Method 1 (current method):
The 3 mem DC's have DDBs selected into them...
Method 2 (possibly more efficient):
The 3 mem DC's would have an 8 bit/pixel DIB Section selected into them.
Now, I am pretty good with Windows GDI... and I realize that the Method 1 (using a Device compatible bitmap) does make the drawing and blt'ing to the screen a little faster... but, the fact is that if the user's screen is set to 16, 24 or 32 bit color, each of the 3 selected bitmaps is 2, 3 or 4 times the size it really needs to be... this could equate to over 10 MBytes of Virtual memory that is used unnecessarilly.
Using Method #2 would keep the virtual memory fixed at 1 byte per pixel for each of the mem DC's DIB Sections, and since each share the same palette, instead of Blting from one mem DC to the other I could just do a CopyMemory, which should be even faster than a Blt... BUT... by using the GDI drawing functions on a DIB section as opposed to a compatible bitmap, will all the GDI functions slow down at all? I realize that the final blt from the level 3 MEM DC to the screen DC would take a little longer as Windows does the conversion... but would all the GDI drawing on the DIB Section backed mem DC's be the same, or slower, or faster than on a DDB basked DC?
In general, given the above scenario, which of the two methods would be faster?
Another factor, and appeal for the DIB Section backed memDC's is that I do some pixel manipulation with SetPixel, that would absolutely be faster by manipulating the DIBSection bits... but, even ignoring that, I am interested in how the performance would compare with the above two methods and straight GDI drawing...