Coverting Image to Byte Array
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”vertical” horizontalAlign=”left”>
<mx:Script>
<![CDATA[
import mx.graphics.codec.JPEGEncoder;
private function copyImage():void
{
var bit:BitmapData=new BitmapData(116,116);
bit.draw(src);
var jp:JPEGEncoder=new JPEGEncoder(75);
var by:ByteArray=jp.encode(bit);
dest.source=by;
}
]]>
</mx:Script>
<mx:HBox width=”100%” height=”50%”>
<mx:Image id=”src” source=”noimage.JPG” height=”125″ width=”125″ />
<mx:HRule width=”5″/>
<mx:Image id=”dest” width=”125″ height=”125″ />
</mx:HBox>
<mx:Button label=”Copy” click=”copyImage()”/>
</mx:Application>
In this I have a source image (id=src) and a destination image.
On click of the copy button I am using a bitmapdata and drawing the
source component in to it and using a jpeg encoder to convert it to byte array and setting that byte array as source for second image,so that the image is copied to it.
Using the same concept you can take screen shots in flex applications and save as image.
I will be Posting that too keep checking in..
View http://www.box.net/shared/q7q67fyss7
feedback