Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Changing colors in a 24-bit bitmap?

This topic is 5128 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to change, on the fly via code, the colors in a 24-bit bitmap? I am not loading them using DDraw. My aim is to be able to, for example, color a character''s bitmap red when he or she is hurt. With color it red I mean changing the hue to more red.

Share this post


Link to post
Share on other sites
Advertisement
The short answer is... you can''t. 24bpp images are not palettized (I''m assuming that''s what you mean?) and therefore you can''t change their colors on the fly.

However, nothing''s stopping you from writing your own recoloring algorithm to redden slightly every pixel or whatnot. If the sprite you want to recolor isn''t too big, you probably won''t have any noticeable performance hit with a per-pixel recoloring algorithm.

I''m not sure what you mean by "I am not loading them using DDraw." What API are you using? GDI? SDL? Textured quad in DirectX/OpenGL? A more complete answer to your question would be difficult to provide without knowing what you''re working with exactly.

Share this post


Link to post
Share on other sites
I dunno... no special API is being used, so I guess it''s the standard windows stuff *shrug*

Still a n00b at this all though... :-/

Share this post


Link to post
Share on other sites
dont quite understand what you mean.i assume you will load the bitmap into a chunk of memory either DirectX surface or just normal array.and when the object is low on health.you wanna it to appear to be "redder",in other word increase red channel of all the pixels in the bitmap.if that is the case,there are several way of doing it.

start from the easiest,you can manually shift the colour of the bitmap to red in Photoshop.and render the red one if it is low on health otherwise draw the normal one.this can be done with just a few extra line of code.the problem with it is that it increases the memory reqirement.imagine if there is 10MB of bitmap,after doing so the size of bitmap increase to its double,coz there is one more same size bitmap need to be loaded.

also you can shift the colour by software pixel by pixel.just add some extra value to the red channel of each pixel before rendering,but considering it is done pixel by pixel.it is gonna be pretty slow.

Share this post


Link to post
Share on other sites
Are you trying to turn the whole character red? if so, blending the texture with the vertex color may acheive the desired effect.. Although just turning things red when they''re getting damage may look odd.. I would suggest using a 2 or 3 texture sets if possible, one for healthy, one for hurt, another for really beat up

Just some possible alternative ideas

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!