Click here to Skip to main content
12,078,370 members (48,084 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++
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 15-Jan-13 14:39pm
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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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
  Permalink  
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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();
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160212.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100