Solved

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

Posted on 2004-09-23
8
905 Views
Last Modified: 2013-12-03
How easy is it to show text over the top of a bitmap image in Visual C++ 6.0?
0
Comment
Question by:pikco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 400 total points
ID: 12135606
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
 

Author Comment

by:pikco
ID: 12139735
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
 

Author Comment

by:pikco
ID: 12139740
sorry, i'm still not really sure how to code this, particularly the "Paint text" bit...

thanks for your help.
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12139823
>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
 

Author Comment

by:pikco
ID: 12154820
ok, i'm not so sure if that CBitmap::CreateBitmap() is going to work for me, but i'll try it soon...

thx
0
 

Author Comment

by:pikco
ID: 12157869
how do i do this?

-create a compatible dc

0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12159660
0
 

Author Comment

by:pikco
ID: 12216374

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

thanks!
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This video teaches viewers about errors in exception handling.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question