Flex: How do I adjust the contrast/brightness of an image inside an image control?
I have an开发者_如何学Go image loaded into an Image
control and I'd like to know the most efficient way that I can darken/lighten the image programatically.
Check out Adobe's BitmapFilter class. You can do some pretty cool things with it. Especially take a look at its derived classes and their usage examples.
Although I went with Robusto's method, I also found this that works well
var a:Number = value * 11;
var b:Number = 63.5 - (value * 698.5);
redValue = greenValue = blueValue = a;
redOffset = greenOffset = blueOffset = b;
var cmf:ColorMatrixFilter = new ColorMatrixFilter(a, 0, 0, 0, b, 0, a, 0, 0, b, 0, 0, a, 0, b, 0, 0, 0, 1, 0);
It was taken from here, Image Manipulation In Flex and there is much more image altering fun as well.
精彩评论