Advertisement

Text Tool Question

Started by February 21, 2001 05:52 AM
8 comments, last by chimplp 23 years, 11 months ago
I''m writing a text tool for my DX8 proggie, that will export all the characters I need to a bitmap, that I can then load in as a texture and pick out the characters I need. My question is... how do I read the bitmap pixels out of the DC in my Win32 app? I''m was going to use TextOut or DrawText to draw to the DC, get the bitmap, and dump to file, but Win32 doesn''t make it easy. I''m looking at GetDIBits, but one of the parameters is the bitmap handle, which is what I don''t have, so anyone any ideas on what to do?
Here''s an off-topic answer to your requirement. I use this method to grab window text for my use. Type a-z,A-Z,0-9 in wordpad and then use IrfanView (freeware) to capture screen (press ''C''). Save the capture image as bmp. QED.

If you want code I recommend codeguru.earthweb.com because I learn loading bitmap there.
Advertisement
Erk, no, that''s horrible, I''m doing it the professional way. As well as generating the text texture, the tool will also save out the positions of the characters and their width so I can pick them out in my text engine when composing on-screen text. Also I want to be able to change my font and size etc... and at some point implement anti-aliasing.

I just want to be able to get the bits out of a Device Context. Anyone?

Tried GetPixel()??
I have thought about it, but that would have to be my last resort.

I want to use something like GetDIBits, or CreateDIBSection and perhaps then copy the bitmap over, but all my efforts are ending up in dead ends.
Solved it, after wading through the pages of Petzold. When you call CreateCompatibleBitmap on a Device Context, the bitmap and the DC become one and the same, so everything that gets done on the DC happens to the bitmap. Then it''s just a call to GetDIBits and hey presto, the btyes of the DC are available to play with!
Advertisement
Or, you can use Bitmap Font Builder?

"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
http://www.gdarchive.net/druidgames/
quote:
Original post by Anonymous Poster

Here''s an off-topic answer to your requirement. I use this method to grab window text for my use. Type a-z,A-Z,0-9 in wordpad and then use IrfanView (freeware) to capture screen (press ''C''). Save the capture image as bmp. QED.

If you want code I recommend codeguru.earthweb.com because I learn loading bitmap there.


Try pressing the print screen button on your keyboard. No special software required.
Argh!(1) Pressing "Print Screen" does not save out the positions of the characters!! I''m not going to go through by trial and error finding out the position of the letters every time I change font or size of text...

Argh!(2) someone''s already wrote a freeware one... dammit
Does anyone understand the copyright issues regarding fonts. Is rendering a font as a bitmap and using that bitmap in your game legal? I''m talking about the standard Windows fonts, such as Arial, etc.

This topic is closed to new replies.

Advertisement