Editing a bitmap in memory with no HDC

I want to create a bitmap in memory (not linked to any window) and then passing it around. I then want to paint to it (edit it), but I see that all the functions require an HDC.
I basically want to be able to use functions like FillRect() with this HBITMAP, but I can't because I have to pass an HDC and so the image will appear somewhere in the window.

I don't want to use libraries because it's just a template code, I have to keep it simple.

Thanks for any hint on how to proceed.
Last edited on
Ok, solved, I didn't think it was possible to pass NULL to CreateCompatibleDC, but it is. So you just have to do this:
1
2
3
4
dcmem = CreateCompatibleDC(NULL);
SelectObject(dcmem,bitmapHandle));
//do your painting
DeleteDC(dcmem);
Topic archived. No new replies allowed.