Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Adding text on to a bitmap handle.

I have loaded a bitmap and have the bitmap handle.Now I have to add some text on to the bitmap and save it. How do I do?
0
rharsha
Asked:
rharsha
1 Solution
 
migelCommented:
Hi!
To add text to the bitmap you must select bitmap into Device Context and simple draw text by API function.
for example:

// Draw text into bitmap at the pt.x, pt.y  position
BOOL DrawTextIntoBitmap(HBITMAP hbm, LPSTR lpszText, HFONT hFont, POINT pt)
{
HDC hdc = CreateCompatibleDC(NULL); // compatible with system screen DC
if (!hdc)
    return FALSE;
HBITMAP hbmOld = (HBITMAP) SelectObject(hdc, hbm);
HFONT hFontOld = (HFONT) SelectObject(hdc, hFont);

TextOut(hdc, pt. x, pt.y,  lpszText, lstrlen(lpszText));
SelectObject(hdc, hFontOld);
SelectObject(hdc, hbmOld);
DeleteDC(hdc);
return TRUE;
}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now