如何在mfc中为图片添加文字? [英] How can I add text to picture in mfc?
本文介绍了如何在mfc中为图片添加文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在visual c ++ 2010中有一个mfc项目,我加载了一个图片whit CImage类。
如何在这张图片上添加文字?
请帮助我!
I have a mfc project in visual c++ 2010,I load a picture whit CImage class.
How can I add text on this picture?
Please, help me!
推荐答案
我使用此代码:
I use this code:
CDC sdc;
sdc.CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
CDC dc;
dc.CreateCompatibleDC(&sdc);
CBitmap bmp;
//bmp.LoadOEMBitmap(IDB_BGBitmap);
bmp.CreateCompatibleBitmap(&sdc, 672, 480);
auto old_bmp = dc.SelectObject(bmp);
dc.FillSolidRect(0,0, 672, 480, RGB(255, 255, 255));
dc.SetBkMode(TRANSPARENT);
dc.SetBkColor(RGB(255,255,255));
dc.TextOut(10, 10, CString("Test"));
dc.SelectObject(old_bmp);
CBitmap bmp2;
bmp2.Attach(bmp.Detach());
CPictureHolder pictholder; //our temp 'converter'
pictholder.CreateFromBitmap(bmp2); //put the image variable into a container
imResult.putref_Picture(pictholder.GetPictureDispatch());
RedrawWindow();
所以我可以在图片上绘制文字;
so I can draw text on picture ;
这篇关于如何在mfc中为图片添加文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文