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

Posts: 42
Registered: ‎08-30-2012
My Device: PlayBook
My Carrier: Aircel

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.layoutData = listRowData;


Posts: 42
Registered: ‎08-30-2012
My Device: PlayBook
My Carrier: Aircel

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

Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: Convert bytearray to Image

Can't you just say




For more info see this thread:



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

Re: Convert bytearray to Image

var loader:flash.display.Loader;




the Loader class has a loadBytes method.


Fromt that point you can choose to copy the bitmapData to a bb10 Image container.

Posts: 327
Registered: ‎12-13-2010
My Device: Bold 9900/Z10 Special Edition
My Carrier: Rogers

Re: Convert bytearray to Image

[ Edited ]

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




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