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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

How to convert Byte Array to bitmap??

Hai..,

             I need to convert byteArray to bitmap. my bytearray holds data for the images my code is..

 

var bmp:Bitmap = new Bitmap(smallImageByteArray as BitmapData);
bmp.opaqueBackground = 0xffffff;
bmp.x = 100;
bmp.y = 200;
addChild(bmp);

 

Anybody have the solution to this problem please help me

Thanks

Deepu

 

Developer
Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings

Re: How to convert Byte Array to bitmap??

You could try something like this:

 

		public function Dummy()
		{
			var data:ByteArray;
			
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
			loader.loadBytes(data);
		}
		
		private function onLoaded(event:Event):void
		{
			var loader:Loader = event.target.loaders as Loader;
			var content:* = loader.content;
			var bitmapData:BitmapData = new BitmapData(content.width,content.height);
			bitmapData.draw(content, new Matrix);
		}

 

 I don't have the time test it right now though.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Developer
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: How to convert Byte Array to bitmap??

[ Edited ]

you need to have width and height beforehand. you could store it when you store the bytearray. after that it's this

 

var ba:ByteArray = ...//your bytearray
var _img:Image = new Image(); //if you need an image

var w:int = imgwidth;
var h:int = imgheight;
var bm:BitmapData = new BitmapData(w, h);
bm.setPixels(new Rectangle(0,0,w,h), ba);
_img.setImage(bm); //if you want to

 

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Highlighted
Developer
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: How to convert Byte Array to bitmap??

i got pixel error in this code
Developer
Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings

Re: How to convert Byte Array to bitmap??

Pixel error?

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Developer
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: How to convert Byte Array to bitmap??

yes
Developer
Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings

Re: How to convert Byte Array to bitmap??

Post your code, post the output... I am not a remote mind reader unfortunately.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Developer
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: How to convert Byte Array to bitmap??

yeah, zezke is right. btw i think you must have done something wrong because I've been using that snippet for more than half a year already

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Developer
Posts: 235
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: How to convert Byte Array to bitmap??


var decoded:ByteArray = Base64.decodeToByteArray(sqlResutl.data[0].largeImage);
//trace(decoded);
/*var LWidth:Number = sqlResutl.data[0].largeImage_width;
var LHeight:Number = sqlResutl.data[0].largeImage_Height;

var rect:Rectangle = new Rectangle(0,0,LWidth,LHeight);
var newBmd:BitmapData = new BitmapData(rect.width,rect.height,true,0x000000);*/

/*var rect:Rectangle = new Rectangle(0,0,sqlResultForIndiaShelf.data[i].smallImage_width,sqlResultForIndiaShelf.data[i].smallImage_height);
var newBmd:BitmapData = new BitmapData(rect.width,rect.height,true,0x000000);
newBmd.setPixels(rect, ba);*/