Changing the color of a bitmap font

Started by
4 comments, last by bose 22 years, 9 months ago
I have a bitmap font I use to draw text with. It is a white font. Using DDraw or GDI, how would I dynamicly change the color of the text? Do I have to map another color over it? If so, is that very fast & efficient? How would I do that? Thanks
Advertisement
How about palettes
Anyone have any examples?
I think you can set a destination color key on the surface and blt a solid color onto it. I haven''t tried that, though.
Destination color keys are not always supported.

What I do in my lib is use source color keys. In my font structure I store the current foreground and the current background color. When I want to change the font (foreground) color, here''s what I do:

1) Set the font surface''s color key to the current font color (in your case, white).

2) Create a new surface of the same dimensions as the font surface

3) Fill the new surface with the color you want to change the font to

4) Blit the font onto the new surface

5) Now you can either switch the surface pointer in your font object to point to the new surface, or blit the new surface on top of the font surface.

6) Depending upon which method you used in step 5, release the surface you no longer need.

That''s it. Nothing to it, and it works quite fast.
Great thanks!

This topic is closed to new replies.

Advertisement