/*
* ColorMatrix Explanation:
* 1 0 0 0 0
* 0 1 0 0 0
* 0 0 1 0 0
* 0 0 0 1 0
* .37 .15 .07 0 1
*
* r = (r*1) + (g*0) + (b*0) + (a*0) + (1*.37) = r + .37
* g = (r*0) + (g*1) + (b*0) + (a*0) + (1*.15) = g + .15
* b = (r*0) + (g*0) + (b*1) + (a*0) + (1*.07) = b + .07
* a = (r*0) + (g*0) + (b*0) + (a*1) + (1*0) = a
*
* Max value for each r,g,b,a value is 1 which means 255. The 5th column is useless except for the last row (5,5).
* Last row is for translation
* Another explanation:
* RED rR gR bR aR 0
* GREEN rG gG bG aG 0
* BLUE rB gB bB aB 0
* ALPHA rA gA bA aA 0
* TRANSFORM fR fG fB fA F
*
* This will convert (R, G, B, A) to:
* R = (R*rR) + (G*gR) + (B*bR) + (A*aR) + (F*fR)
* G = (R*rG) + (G*gG) + (B*bG) + (A*aG) + (F*fG)
* B = (R*rB) + (G*gB) + (B*bB) + (A*aB) + (F*fB)
* A = (R*rA) + (G*gA) + (B*bA) + (A*aA) + (F*fB)
*/
atsofttech
Participant
830 Points
269 Posts
Re: ColorMatrix class?
Apr 03, 2007 05:18 AM|LINK
This may help you to understand better. Taken from http://vbforums.com/showthread.php?s=8fb475c05b2efd3b456e56e83a614a69&threadid=258872
/*
* ColorMatrix Explanation:
* 1 0 0 0 0
* 0 1 0 0 0
* 0 0 1 0 0
* 0 0 0 1 0
* .37 .15 .07 0 1
*
* r = (r*1) + (g*0) + (b*0) + (a*0) + (1*.37) = r + .37
* g = (r*0) + (g*1) + (b*0) + (a*0) + (1*.15) = g + .15
* b = (r*0) + (g*0) + (b*1) + (a*0) + (1*.07) = b + .07
* a = (r*0) + (g*0) + (b*0) + (a*1) + (1*0) = a
*
* Max value for each r,g,b,a value is 1 which means 255. The 5th column is useless except for the last row (5,5).
* Last row is for translation
* Another explanation:
* RED rR gR bR aR 0
* GREEN rG gG bG aG 0
* BLUE rB gB bB aB 0
* ALPHA rA gA bA aA 0
* TRANSFORM fR fG fB fA F
*
* This will convert (R, G, B, A) to:
* R = (R*rR) + (G*gR) + (B*bR) + (A*aR) + (F*fR)
* G = (R*rG) + (G*gG) + (B*bG) + (A*aG) + (F*fG)
* B = (R*rB) + (G*gB) + (B*bB) + (A*aB) + (F*fB)
* A = (R*rA) + (G*gA) + (B*bA) + (A*aA) + (F*fB)
*/