replacing a color

Started by
5 comments, last by Yanroy 20 years, 8 months ago
I''m using DD, I''m not certain which version, but it''s not the final one. Is there a way to change one color to another color when blitting, like a colorkey, except not transparent? I realize I can do this with 2 or 3 blits using several color keys, but I''d rather not have to do that... I need something fast for my font engine. I''m using 16bit colors if that matters. Right now all I''ve got is blue text, because that''s what the font''s BMP is. I''d like to be able to change the text color without recreating the BMP in a different color. Thanks. --------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

Advertisement
Hi - I''m not sure that this will work, but give it a try:

1) Make the font''s BMP text white
2) Make a material of the color that you wish to assign
3) Assign the material to d3d
4) render the font
Unless I''m missing something obvious, the material colors should tint the white text of the font bmp, thus producing the color that you want.

Hope this helps-

BM
He''s using DirectDraw.

It''s a sinch to do in Direct3D, but I don''t think there''s a DD way to do it short of manually settings every pixel.
ohh - oops, didn''t see the DD part - sorry
Couldn''t he just use a color key (Set to white or whatever unused color) for the destination surface and then just blit a colored box over the text and thus creating different colored texts without having to manually color every font in a bitmap?

I''m just learning color keys so I can''t really work it out in code yet, but in theory that would work. I believe there is even a DirectX SDK example of this.

I know only that which I know, but I do not know what I know.
Daishi, that would work, but unfortunately, there are two problems with it. One is that many video cards don''t support destination color keys (they only support source keys). The other problem is that it requires at least 2 blits. I used a method similar to this once before with a tile engine and it brought the framerate down a lot. If I display any significant amount of text, at 2 blits per character, that''s a lot of blits! Thanks for your replies so far.

--------------------


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming

You are unique. Just like everybody else.

"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

while your on it how would you do it in D3D?
Wouldn''t a good solution in DD be to use paletted bitmaps and use palette switching? I don''t know much about this, but the only problem I can see is it not letting you blit between different color depths.

This topic is closed to new replies.

Advertisement