Manage bitmap output levels

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.
<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)" />

Retrive image type, width and height of png, jpg, gif using nabiro

With these few lines of code you can easly retrive type and size of an image
var imageInfo:ImageInfo = new ImageInfo(myByteArray);
imageInfo.extractType();
imageInfo.extractSize();
trace(imageInfo.type.toString());
trace(imageInfo.width.toString());
trace(imageInfo.height.toString());

How to use SmartDragManager class included in Nabiro

This is a sample application that shows you how simple is add and remove drag and drop functionalities to any DisplayObject component using Nabiro's SmartDragManager class.
Note that you need Nabiro 0.950 or major
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
creationComplete="addDrag()"
xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Script>
<![CDATA[

import mx.events.DragEvent;
import com.gnstudio.nabiro.utilities.SmartDragManager;




private function onChange(e:Event):void{

if(e.currentTarget.selected == true){

addDrag()

}else{

removeDrag()

}

}

private function addDrag():void{

SmartDragManager.makeDraggable(myImage);//make the image on the left draggable
SmartDragManager.makeDraggable(myImage2,false);//make the image on the right draggable without the proxy image
SmartDragManager.makeDroppable(myContainer,onDrop);//make the container droppable

}

private function removeDrag():void{

SmartDragManager.removeDrag(myImage);//remove the drag
SmartDragManager.removeDrag(myImage2);//remove the drag
SmartDragManager.removeDrop(myContainer);//remove the drop

}

private function onDrop(e:DragEvent):void{

var obj:Object = e.dragSource.dataForFormat('item');

var bitmapData:BitmapData = new BitmapData(obj.width, obj.height, true, 0x00000000);
bitmapData.draw(obj as IBitmapDrawable);

var bitmap:Bitmap = new Bitmap(bitmapData);

var img:Image = new Image();
img.source = bitmap;

myContainer.addChild(img);

}

]]>
</mx:Script>


<mx:HBox horizontalCenter="0">

<mx:Image
toolTip="Drag Me"
id="myImage"
source="assets/nabiro_logo-1.png"
/>
<mx:Image
toolTip="Drag Me"
id="myImage2"
source="assets/nabiro_logo-1.png"
/>

</mx:HBox>

<mx:CheckBox
label="Enable Drag"
horizontalCenter="0"
y="130"
selected="true"
change="onChange(event)"
/>


<mx:Panel
id="myContainer"
title="Drop Nabiro logo here"
horizontalCenter="0"
y="150"
width="500"
height="250"
/>


</mx:Application>

Dispatch events between native windows

I was looking to a way to dispatch events between ultiple windows in an AIR application and, after I found on google only some solution that state to send a reference of the target for the event to the new window uing public properties, I came out with a more elegant solution that involves a new class added to nabiro.
The idea is that this class acts like a bridge on which is possible to register a DisplayObjetc for a specific message (i.e. the event type), the snippet represent only the simple usage of thebridge for register a new DisplayObject, attached there is the complete sample.
bridge = WindowsBridge.getInstance();
bridge.register(this, "Test");

addEventListener("Test", onTest);

// Window dispatch code
var test:WindowsBridge = WindowsBridge.getInstance();

test.dispatchEvent(new IntraWinComEvent(IntraWinComEvent.DEFAULT, new Event("Test")));