Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text in DIB 1

Status
Not open for further replies.

hennep

Programmer
Dec 10, 2000
429

How can I get text in a device independent bitmap, without using third party controls or libraries.
 
> How can I get text in a device independent bitmap

What is the context in which you 'have a DIB'? It's in a file on disk? In memory? If in memory, in what form?

One way to alter a DIB in any fashion is to select it into a Device Context and then use the appropriate API's to alter the DC, i.e.:

BitBlt()
StretchBlt()
DrawTextEx()
FillRect()
RoundRect()
.... etc.

Then obtain the changed Bitmap from the DC using GetDIBits()

Working with the GDI API covers a large body of information. I cannot possible cover it in a forum message. If you need to work with the GDI API's in Windows you should obtain one of the numerous books that cover the topic in detail.

Hope this helps
-pete
 
I have a pointer to the bits. (BYTE*) I have already been trying the CDC::DrawText with no effect (not to blame CDC or micosoft, I'm probably too stupid). If I cannot find any sample code on the net the last option left is to buy a book.

 
There are plenty'o samples on
Good books are a great way to go for a large subject such as this. The online samples and examples tend to leave out much of the ground work for understanding the principles of the technology.

Boy, that sounds just awful, but hopefully you get the idea.
-pete
 
Pete,

Do you know how to work with "Device Contexts" in a console application. I want to create an application that manipulates a bitmap without showing in on the screen.
So far the only way to write in the DC was in the OnDraw event, everything else failed.

Hennie
 
Hennie,

You can create a memory device context and use that. Look at using CDC::CreateCompatibleDC() passing it a DC of the desktop. It's been a long time but I think it goes something like this:

CClientDC dc(NULL); // this should give you the desktop dc
CDC memdc;
memdc.CreateCompatibleDC( &dc);

// now do what you want with the memory device context

Hope this helps
-pete

 
When I use the CreateCompatibleDC function, will I be able to handle images with 32 bit colors on a pc with a 16 color screen ?
I don't need to show the pictures, just do some BitBlt manipulations.
 
You might have to set up the palete yourself to handle the color depth you desire. That is definitly beyond my 'in memory' knowledge.

Check out MSDN and look for articles and books by Nigel Thompson. He did a great book years ago that covered palettes in Win32

Good luck
-pete
 
thanks,

I will have a look at it.

Hennie
 
This gives me a lot to read :)

thanks,

Hennie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top