12-07-2012 01:40 AM
Hi to everyone I want to convert byte array to image.
can any one help me here is my cide
var file:FileReference = FileReference(FileArray[i]);
file.addEventListener(Event.COMPLETE,openFile); file.load();
protected function openFile(event:Event):void
{
var image:Image = new Image();
var fileref:FileReference = FileReference(event.target)
var byteArrayToProcess:ByteArray = fileref.data ;
var filename:String = fileref.name;
image.setImage(decrypt(byteArrayToProcess));
image.layoutData = listRowData;
bottomContainer.addChild(image);
}
12-07-2012 03:51 AM
I converted byterray to bitmap is succesfully but i unable convert bitmap to image can anyone help me
to convert bitmap to image or
bytearray to image
iam waiting
Thanks in advance
12-07-2012 07:12 AM
Can't you just say
image.setImage(bitmapData);
?
For more info see this thread:
12-10-2012 03:37 PM
var loader:flash.display.Loader;
loader.loadBytes(byteArrayToProcess);
this.addChild(loader);
the Loader class has a loadBytes method.
Fromt that point you can choose to copy the bitmapData to a bb10 Image container.
12-16-2012 05:10 AM - edited 12-16-2012 05:14 AM
I have had very good experiences using the PNGencoder Class for AS3.
https://github.com/mikechambers/as3corelib/tree/ma
It uses a lot less code than developing your own solution, and it's a very lightwheight class to add to your App, and has no noticable overhead on your application.
function onLoad(e:Event):void{
TempImage = new BitmapData(165, 165, false, 0x00FFFFFF); TempImage.draw(evt.currentTarget.loader,null,null, BlendMode.NORMAL,null,true);
}
var YourPNG:ByteArray = PNGEncoder.encode(TempImage);
After this you can use the image to save or as a display object