I am trying to move everything from GDI to GDI+. As it stands I am drawing to a buffer DC (GDI). I am wanting to have it instead drawn to a HBITMAP and only have it drawn once. I have tried things with pointers and Image, but could not find anything useful. There is no istream or file, and I am not using the flat api version (found a constructor for that.)
Asked
Active
Viewed 1,580 times
-3
-
1If you want to move to GDI+ then stop using HBITMAPs. A "buffer DC" ought to be a Bitmap, preferably in the 32bppPARGB pixel format to make it fast. You draw into it with Graphics::FromImage(). But if you need it then you go from a HBITMAP to a Bitmap with Bitmap::FromHBITMAP(). – Hans Passant Jun 11 '14 at 18:43
1 Answers
-1
Solved. Here is how you can create the bitmap and then proceed to draw.
Graphics g(hDC);
Bitmap foobar(100,100,PixelFormat32bppPARGB);
g.DrawImage(&foobar,100,100);
SolidBrush brush(Color::Blue);
g.FillRectangle(&brush, 0,0,10,10);

Evan Carslake
- 2,267
- 15
- 38
- 56