-
November 30th, 2003, 09:34 PM
#1
how to output text in DIB??
below is my code:
-------------------------------------------------
HDC hDC;
HFONT hFont;
RECT rect;
DWORD* pBitmapBits;
BITMAPINFO bmi;
HBITMAP hbmBitmap = NULL;
hDC = CreateCompatibleDC( NULL );
SetMapMode( hDC, MM_TEXT );
ZeroMemory( &bmi.bmiHeader, sizeof(BITMAPINFOHEADER) );
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = (int)100;
bmi.bmiHeader.biHeight = (int)100;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biBitCount = 32;
hFont = CreateFont( 0, 0, 0, 0, FW_BOLD, FALSE,
FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,VARIABLE_PITCH, _T("Arial"));
SelectObject( hDC, hFont );
hbmBitmap = CreateDIBSection( hDC, &bmi, DIB_RGB_COLORS,
(void**)&pBitmapBits, NULL, 0 );
SelectObject( hDC, hbmBitmap );
SetTextColor(hDC, RGB(100,100,100));
SetBkColor( hDC, RGB(255,255,255));
SetBkMode(hDC, OPAQUE);
SetTextAlign( hDC, TA_TOP );
ExtTextOut(hDC, 0, 0, 0, NULL, str, strlen(str), NULL);
-------------------------------------------------
then I watch memory at the pointer pBitmapBits.It is still all 0x00.
I had check return value of each function.and it's all OK.
where's the problem??
-
November 30th, 2003, 11:30 PM
#2
Sorry, this might appear a bit sudden, but did you load anything into str? I cant see it if you did.
Microsoft LVP - Least Valuable Professional
Please rate this post... Pleeeeeeaaassee!!!
-
November 30th, 2003, 11:50 PM
#3
oh,
that str is a parameter and it has load some words.
sorry.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|