Text Tool Question
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?
February 21, 2001 08:34 AM
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.
If you want code I recommend codeguru.earthweb.com because I learn loading bitmap there.
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?
![](smile.gif)
I just want to be able to get the bits out of a Device Context. Anyone?
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.
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!
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/
![](wink.gif)
"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
Argh!(2) someone''s already wrote a freeware one... dammit
![](tongue.gif)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement