Page 1 of 1

[25 Jun 2007] tint

Posted: Sat Jun 13, 2020 5:31 pm
by lazi
Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 25 Jun 2007 12:50:06 +0100

Hello Andreas!

I am playing with the tint functions (setlayertint, tintbrush...) and I have to make a grayscale image that results the desired colors by tinting. I figured out that this does not do a simple rgb add operation. It would be helpful if you could describe that algorithm.

Thanks in advance!

[06 Jul 2007] Re: tint

Posted: Sat Jun 13, 2020 5:31 pm
by airsoftsoftwair
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 06 Jul 2007 20:56:15 +0200
Hello Andreas!

I am playing with the tint functions (setlayertint, tintbrush...) and I have to make a grayscale image that results the desired colors by tinting. I figured out that this does not do a simple rgb add operation. It would be helpful if you could describe that algorithm.
Tint algorithm is implemented in the following way:

Code: Select all

dr = dr + (((r - dr) * ratio) >> 8);
dg = dg + (((g - dg) * ratio) >> 8);
db = db + (((b - db) * ratio) >> 8);

r,g,b = tint color 
dr,dg,db = pixel to tint
ratio=0-$ff