Click to See Complete Forum and Search --> : Creating bitmaps at runtime


Daniel B. Sigurgeirsson
July 28th, 1999, 01:41 PM
Has anyone done something like that? What I would like to do is to create a bitmap, write onto it and save it to file. What actually goes into the bitmap is only known at run time. It would be very nice if I could do something like this:
CDC dc;
CBitmap bm;

dc.Rectangle( rcRect );
dc.DrawText( _T("Hello world"), rcRect, DT_SINGLELINE | DT_CENTER | etc );
dc.SaveToBitmap( bm );



but I can't. Or can I? What I really want to do is to create a Device-independent bitmap so technically I should not need to create a CDC variable (which after all is _DEVICE_ context and is therefore device-dependent) but then it would be nice to have all the CDC-functions (like BitBlt, DrawText etc). But I would also like to be able to accomplish this in any program, not just a Window-based application. So I would therefore not like to rely on solutions like "CClientDC dc(this);" in a view or in a dialog.

Any ideas?

With best regards,
Daniel B. Sigurgeirsson