This might not be the most elegant solution, but since you know 128 =
full shift to new value and 0 and 256 = no shift to new value you can
use a formula to calculate the shift and then build the new rgb value
after the calculations are complete.
Assuming you want a linear relationship, it would look something like:
GRAPH: Multiplier vs Value:
*0 128 256
1 / \
. / \
. / \
0 / \
[pardon my ascii art!!]
CODE:
//check if original R/G/B component value is above middle point or
//bellow it:
if (originalValue:Number < 128):Number {
multiplyer = 128 * (originalValue/128);//ratio
} else {
multiplyer = 128 * ((256-originalValue)/128);//ratio
}
//originalValue is the r or g or b parameter you are
//transforming, you run this function once per r,g,b component
//in other words: run this function 3 times! for full r/g/b
//or use a matrix transform...
newValue = valueToConvert * multiplyer;
return newValue;//assuming you put this code in a function call?
}
haven't checked the math, there might be an error in my formula...
:P
hope this helps!
with kind,
seb.
Mike Mountain wrote:
Hey guys
I'm working with greyscale images - assume neutral colour temperature is
50%
grey. These are shaded from white to black, white representing light, black
shading, and all the variable shades in between etc.
I need to tint the greyscale bitmapData to produce a shaded coloured image
using the colorMatrixFilter() from an RGB or Hex value.
so if the whole image was 50% grey (ie. r=128, g=128, b=128) it should
become r=256,g=0,b-0 - black should stay black, white should stay white but
the colours in between should be shades of red.
Anyone got a clue how I can do this?
Cheers
Mike
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com