I want to color byte array of image pixels with any color say Color(25,25,50) preserving intensity of the original color.
Formula to calculate intensity of color: 0.3*R + 0.59*G + 0.11*B
Suppose current color of a image pixel is Color(50,25,23).
current color - Red part - 50, Green part - 25 & blue part - 23.
apply color - Red part - 25, Green part - 25 & blue part - 50.
if I use bitwise AND opration I will get
Red part - 25, Green part - 25 & blue part - 23. ie. Color(25,25,23). thus intensity changes.
As you can see apply color has blue part prominant that means the end result should be some shade of blue with same intensity as the current color.
Can anybody give me exact formula or logic for this.
BE (Computer Science) SCJP 4 (80%) SCWCD 5 (97%) IBM CAD(98%) IBM CAppD(100%) IBM SD(100%)