cyberbum
asked on
Copying a CFont to a CBitmap
I was wondering if there is any way to blit a CFont to a CBitmap. Right now, I can use DrawText but that only outputs to a CDC...is there any way to get the output of the drawtext to the CBitmap?
ASKER
When I do the DrawText, the bitmap ends up having a white rect in it...this is what I do:
CDC dc;
dc.CreateCompatibleDC(NULL );
// Select the bitmap into the DC
CBitmap * pOldBmp = dc.SelectObject(CBitmap::F romHandle( pImg->m_st Image.m_hB itmap));
// Set Font
CFont* pOldFont = dc.SelectObject(&m_fontFri ends);
// Set TextColor
dc.SetTextColor(m_crFriend sFont);
// DrawText
dc.DrawText(pFriend->GetNi ckName(), &rectText, 0);
// Cleanup
dc.SelectObject(pOldFont);
dc.SelectObject(pOldBmp);
Also, where did you get your CMemDC class? I can't even construct mine without asserting..
CDC dc;
dc.CreateCompatibleDC(NULL
// Select the bitmap into the DC
CBitmap * pOldBmp = dc.SelectObject(CBitmap::F
// Set Font
CFont* pOldFont = dc.SelectObject(&m_fontFri
// Set TextColor
dc.SetTextColor(m_crFriend
// DrawText
dc.DrawText(pFriend->GetNi
// Cleanup
dc.SelectObject(pOldFont);
dc.SelectObject(pOldBmp);
Also, where did you get your CMemDC class? I can't even construct mine without asserting..
ASKER
Ok, it was my fault...my font color was the same as the background color:)
Add a comment so I can give you your points
Add a comment so I can give you your points
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
// CBitmap bmp;
CDC MemDC;
MemDC.CreateCompatibleDC(N
CBitmap *pOldBmp = MemDC.SelectObject(&bmp);
// MemDC.DrawText
MemDC.SelectObject(pOldBmp