Overlaying text over top of a bitmap image in Visual C++.

How easy is it to show text over the top of a bitmap image in Visual C++ 6.0?
pikcoAsked:
Who is Participating?
 
Jaime OlivaresSoftware ArchitectCommented:
It is very easy.
In your "Paint" event (usually OnPaint or OnDraw):
Paint Bitmap:
-create a compatible dc
-Select bitmap into this dc
-copy to current dc using BitBlt function
Paint Text:
-now create a font object
-select it into current dc
-select font color and alignment
-draw text over bitmap coordinates.
0
 
pikcoAuthor Commented:
So that would be using a CBitmap object then, to "Select the bitmap into the dc"

My picture is currently an array of bytes, is there any way to read this into a CBitmap?
0
 
pikcoAuthor Commented:
sorry, i'm still not really sure how to code this, particularly the "Paint text" bit...

thanks for your help.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
Jaime OlivaresSoftware ArchitectCommented:
>My picture is currently an array of bytes, is there any way to read this into a CBitmap?
You can do it with CBitmap::CreateBitmap() easily, if your array is properly ordered. Take a look to this previous question:
http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_20319663.html

>sorry, i'm still not really sure how to code this, particularly the "Paint text" bit...
use CDC::TextOut() function, is as easy as:

CString text="some text";
int x=15;
int y=20;
yourdc.SetTextColor(RGB(255,255,0)); // Yellow
yourdc.TextOut(x, y, text);
0
 
pikcoAuthor Commented:
ok, i'm not so sure if that CBitmap::CreateBitmap() is going to work for me, but i'll try it soon...

thx
0
 
pikcoAuthor Commented:
how do i do this?

-create a compatible dc

0
 
Jaime OlivaresSoftware ArchitectCommented:
0
 
pikcoAuthor Commented:

i finally had some time to try it out, works great.

thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.