Imagine to want to reach the same effect of the output levels panel you have in Photoshop through ActionScript, you can get the result by remaping the color channel values in an image that has up to four arrays of color palette data, one for each channel.

In order to do this you can simply use the paletteMap() method of the BitmapData and recalculate the values for each channel to use inside the method accordingly to 2 different points (black and white).
Download the last release of nabiro to get the class that do the job for you.

In order to do this you can simply use the paletteMap() method of the BitmapData and recalculate the values for each channel to use inside the method accordingly to 2 different points (black and white).
Download the last release of nabiro to get the class that do the job for you.
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import com.gnstudio.nabiro.ui.images.utils.OutputLevels;
import mx.events.SliderEvent;
private var bmd:BitmapData;
override protected function childrenCreated():void{
super.childrenCreated();
var url:URLRequest = new URLRequest("central_park.jpg")
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageCompleted);
loader.load(url);
}
private function imageCompleted(e:Event):void{
e.target.removeEventListener(e.type, arguments.callee);
bmd = Bitmap(e.currentTarget.content).bitmapData;
var output:OutputLevels = new OutputLevels(100);
image.source = new Bitmap(output.setLevels(bmd.clone(), 0, 200));
}
private function outputLevels(e:SliderEvent):void{
var output:OutputLevels = new OutputLevels(e.target.values[0] + (e.target.values[1] - e.target.values[0]) / 2);
image.source = new Bitmap(output.setLevels(bmd.clone(), e.target.values[0], e.target.values[1]));
}
]]>
</mx:Script>
<mx:Image id="image" verticalAlign="middle" complete="imageCompleted(event)" horizontalAlign="center" left="30" right="30" top="30" bottom="30"/>
<mx:HSlider bottom="5" right="30" left="30" minimum="0" maximum="255" thumbCount="2" values="[0, 255]" liveDragging="false" change="outputLevels(event)" />


