Drawing text to off-screen buffer.


2003-10-08 08:46:41 PM
cppbuilder7
I need to write text (and create graphics...) in an off screen bitmap
buffer, and this gives me a little headache.
My buffet is 3x8 bits deep (RGB) and e.g. 1280x1024 pixels in width
and height.
I try to use simple code:
BITMAP bm;
bm.bmType = 0;
bm.bmWidth = 1280; //buffer width
bm.bmHeight = 1024; //buffer height
bm.bmWidthBytes = 3 * bm.bmWidth;
bm.bmPlanes = 1;
bm.bmBitsPixel = 24;
bm.bmBits = malloc( bm.bmWidthBytes * bm.bmHeight );
memset(bm.bmBits, 128, bm.bmWidthBytes * bm.bmHeight ); // Init to
soemthing sane....
HBITMAP hbm = CreateBitmapIndirect(&bm);
HDC dc = CreateCompatibleDC(NULL);
SelectObject(dc, hbm);
TextOut(dc,10,10,"Hello",strlen("Hello"));
But nothing really happens to the buffer? Do I miss something basic?
Thanks for using a split-second on this.
Niels