Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem: open a bitmap file and draw a string on it with C++ language, do you think about this? Please help me do this, thanks.
Posted
Comments
Sergey Alexandrovich Kryukov 15-Jan-13 19:52pm    
Your platform?
—SA
Andrewpeter 16-Jan-13 8:44am    
Thanks SA for your question, I code "Console" platform. Hope you help me.
Sergey Alexandrovich Kryukov 16-Jan-13 13:15pm    
Sorry, "Console" is not a platform. And, with your problem, it does not matter at all if you use console or not. Do you mean Windows, Linux, something else?
—SA
Andrewpeter 16-Jan-13 22:28pm    
My platform is Windows. Thanks.

I wanted to advise you to find it out from the CodeProject article referenced below, but wasn't sure you are asking about Windows. Still not 100% sure, but I saw that you mentioned MFC and some of your other questions was for Windows. Please see:
Drawing lines, shapes, or text on bitmaps[^].

Please see my comments to your question, and, next time, please understand that the platform tag is almost always important for your question.

—SA
 
Share this answer
 
Comments
Andrewpeter 16-Jan-13 22:27pm    
Yes sir, it's great. Thank you very much.
Sergey Alexandrovich Kryukov 16-Jan-13 22:43pm    
My pleasure.
Good luck, call again,
—SA
If you're going to do it with the Windows API (really it's GDI component), You need to know about handling memory DC's. That's quit a long topic give you a full answer.

Here're some sources :
>> Programming Windows Charles Petzold (see chap. 14) -http://www.amazon.com/Programming-Windows%C2%AE-Edition-Microsoft-Series/dp/157231995X/ref=sr_1_1?ie=UTF8&qid=1358346269&sr=8-1&keywords=programming+windows
>> A Codeproject Article - http://www.codeproject.com/Articles/224754/Guide-to-Win32-Memory-DC
>> Search google - There's plenty of things about DCs
 
Share this answer
 
hi dear sergey
if you work with visual c++, below code helps you:

CImage i;
i.Load(_T("a.bmp"));
CDC cdc;
cdc.Attach(i.GetDC());
cdc.TextOut(_T("Hello world"),10,10);
cdc.Detach();
i.ReleaseDC();
 
Share this answer
 
Comments
Andrewpeter 16-Jan-13 8:45am    
Thanks, your code is used for MFC?
Sergey Alexandrovich Kryukov 16-Jan-13 22:43pm    
Shared between ATL and MFC:
http://msdn.microsoft.com/en-us/library/bwea7by5%28v=vs.110%29.aspx

—SA
Sergey Alexandrovich Kryukov 16-Jan-13 22:41pm    
Who do you call Sergey?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900