[GDI] Does anyone know how to create a memory DC that is not 1x1 monochrome?

Started by
4 comments, last by uncle_rico 17 years, 7 months ago
...without loading a bitmap, that is? When I create a memory DC and make it compatible with the DC of my window, it makes it compatible in the sense that it has the same functionality, but according to MSDN, the DC is only 1x1x1-bit. Is there a way to just specify the dimensions and bit depth that I want? It seems that the only way to do that is to load a bitmap into it which, itself, has the pixel dimensions and bit depth that I need. I can load a blank bitmap if needed, but I'd rather not because it seems like a hack.
Advertisement
Selecting a bitmap into the DC is actually the way to go.

The DC is merely a interface that lets you draw stuff to something, but A DC isn't a drawing target by itself. If you are drawing to the screen, it has the screen as drawing target, but if you want to draw to an offscreen target, you have to create this drawing target yourself, as a bitmap.
Ah, I understand. Thanks! Is there any way to generate a blank bitmap programatically, instead of loading it from the file?
I'm using MFC, by the way, and it looks like the CreateBitmap method of CBitmap will allow me to do exactly what I'm looking for. Thanks!
You want CreateCompatibleBitmap.

The DC you pass in should be the original DC, not the memory DC.
-Mike
Thank you!

This topic is closed to new replies.

Advertisement