CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    5

    Unhappy 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??

  2. #2
    Join Date
    Aug 2001
    Location
    Sydney, Australia
    Posts
    813
    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!!!

  3. #3
    Join Date
    Aug 2003
    Posts
    5
    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
  •  





Click Here to Expand Forum to Full Width

Featured