Tinting sprites by luminosity value.

BlitzMax Forums/BlitzMax Beginners Area/Tinting sprites by luminosity value.

Ryan Burnside(Posted 2007) [#1]
hello

I'm looking to colorize my grayscale sprites without just mixing in a color. If you have played of the older arcade shooters you see multicolored fonts but they seem to be tinted differently than tinting in blitzmax works. Could I use blending with regard to the luminosity value instead of just mixing the target image with the set color? I need this done dynamically for my project..
Using normal colorizing would destroy the white reflection and ignore current color values.




kronholm(Posted 2007) [#2]
Probably converting the image to HSV values, then adjusting whatever H/S/V value you need, I guess Hue, then converting back to RGB should work for you as it did for me:

http://www.blitzbasic.com/Community/posts.php?topic=68045


sswift(Posted 2007) [#3]
I think this might work.

1. Set the black and white sprite's color to red. Draw it.
2. Set the black and white sprite's color to 127, 127, 127. Set blend mode to ligthblend. Draw it at the same location.

By setting the color to gray in the second step, any grayscale values at or below 127 will become 0.

When the image is then added to the prior result, those sections which have a color value at or below 127 will not add to the color of the background.

And those sections which had a color value of 127 originally will be 50% red because you drew the image multiplied with red.

If you would like the gray parts of the black and white image to be red 255 instead of red 127, then do step 1 twice, but set the blend mode to lightblend after you do it the first time.


ImaginaryHuman(Posted 2007) [#4]
Looks like all that happens is the grayscale image is moved into one of the color channels without modification. ie if you put it in the red channel it becomes red values with no change to the luminosity. With that method you have the option of primary and secondary colors as your hue. ie change from a luminosity pixmap to a RED pixmap.


Ryan Burnside(Posted 2007) [#5]
So is this possible to do dynamically?


sswift(Posted 2007) [#6]
Yes, and my description there explains how to accomplish it. There's no one step process, if that's what you're asking for! :-)