I remember the amount of time and trouble it took me to properly set up rendering to a GDI memory bitmap and then blit that to the screen (that is, blit it to some window's DC). So after reading a post on GameDev.net asking about it, I decided to post the code that I wrote to encapsulate this stuff. The download includes the CMemoryBitmap class and a simple application demonstrating how to use it. Note that using a 32bpp bitmap is much faster than using a 24bpp one, so use that even if you won't be using the alpha channel.
I make no claims about the correction or optimality of the code. You are free to use the code anyhow you like, but it would be nice to credit me somehow.
If you find errors in it, or if you fix any issues with it, or if you just find it useful, leave a comment to let me know please.
¶ | Used tags: programming, sample, win32