Solved

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

Posted on 2004-09-23
8
859 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
  • 5
  • 3
8 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 400 total points
Comment Utility
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
Comment Utility
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
Comment Utility
sorry, i'm still not really sure how to code this, particularly the "Paint text" bit...

thanks for your help.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
>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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:pikco
Comment Utility
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
Comment Utility
how do i do this?

-create a compatible dc

0
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
0
 

Author Comment

by:pikco
Comment Utility

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

thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PYTHON: Updating local variable in .TPL file 24 123
noX challenge 17 75
mapShare challenge 13 67
wordmultiple challenge 12 89
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
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…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

771 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now