• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 933
  • Last Modified:

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?
0
pikco
Asked:
pikco
  • 5
  • 3
1 Solution
 
Jaime OlivaresCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Jaime OlivaresCommented:
>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 OlivaresCommented:
0
 
pikcoAuthor Commented:

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

thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now