Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Contributor
satishmukku
Posts: 42
Registered: ‎08-30-2012
My Device: PlayBook

Convert bytearray to Image

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);
	}

 

Contributor
satishmukku
Posts: 42
Registered: ‎08-30-2012
My Device: PlayBook

Re: Convert bytearray to Image

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

Developer
pyth
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane

Re: Convert bytearray to Image

Can't you just say

image.setImage(bitmapData);

?

 

For more info see this thread:

http://supportforums.blackberry.com/t5/Adobe-AIR-Development/Code-for-saving-an-image-to-application...

 

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Contributor
bobbydriscol
Posts: 23
Registered: ‎05-04-2012
My Device: Playbook, 9670, 9800, 9350

Re: Convert bytearray to Image

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.

Developer
tensioncore
Posts: 326
Registered: ‎12-13-2010
My Device: Bold 9900/Z10 Special Edition

Re: Convert bytearray to Image

[ Edited ]

I have had very good experiences using the PNGencoder Class for AS3.

 

https://github.com/mikechambers/as3corelib/tree/master/src/com/adobe/images

 

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

 

CEO/Lead Developer - Tensioncore™ Design Studios
http://tncr.ws/ - ShortenThis!™ for Blackberry Playbook | ShortenThis!™ for BlackBerry® 10
The Periodical Toe A highly informative Table of Elements
DrawThis! A fun drawing app for the BlackBerry® PlayBook™!
http://www.tensioncore.com/ - Tensioncore™ Web Hosting