Archived

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

cyberia_2ooo

color switching

Recommended Posts

S1CA    1418
If you mean changing a specific colour in a sprite at drawing time, what you could do is:

1) render a rectangle the same size as the sprite which is all colour B at the location you want to render the sprite.

2) set the colour key for the sprite surface to colour A

3) draw the sprite on top of the rectangle which was drawn in 1)


You could also do that into a temporary surface if you''ll be doing it a lot.



--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
cyberia_2ooo    122
using a sprite that is all colur A is to much of a memory hugger.

and i already have another keyed color which is not color A.

thanx any way...

i did it the hard way.
since i don''t need to that on drawing time.
i locked the surface, and checked each pixel if it is of color A, and if so, changed it to color B, slow, but reliable

Share this post


Link to post
Share on other sites
S1CA    1418
You don''t need to use a sprite which is all of colour A though...
just use a Blt() to fill in one colour - it requires no storage.
If you use a temporary surface then you can change the key back afterwards e.g.:

1) you have *one* temporary surface in the application, created when it starts up. Call this lpDDSTemp.

2) use a Blt() colourfill to change all of lpDDSTemp to colour B

3) say the surface your sprite is on is called lpDDSSprite, set the colour key for lpDDSSprite to colour A

4) Blt() from lpDDSSprite to lpDDSTemp with colour keying enabled. This replaces colour A with colour B in lpDDSTemp

5) Blt() from lpDDSTemp to lpDDSSprite with colour keying disabled, this copies the sprites back.

6) set the colour key for lpDDSSprite to the proper/original colour key

7) lpDDSTemp is now unused and can be used for any other purpose - having a temp buffer around is always handy...


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites