Thinking about this a bit more, I wouldn't use loadBytes

If the main app had
<mx:Image id="img" />

The steps to get the byte array should be:
Var ba:ByteArray = img.content.bitmapData.getPixels();

On the other side, if you have said byteArray, and the width and height, then 
it should be:

Var bd:BitmapData = new BItmapData(width, height);
bd.setPixels(ba);
img2.source = new Bitmap(bd);

where img2 is defined in the other app as:
<mx:Image id="img2" />

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: [email protected] [mailto:[email protected]] On Behalf 
Of rob_mcmichael
Sent: Friday, April 10, 2009 12:20 PM
To: [email protected]
Subject: [flexcoders] Re: Marshall Plan: Loading images from byteArray





> You didn't saw you were stringifying the bytearray. Made me wonder if you'd 
> posted the right code or described your steps correctly.

Oops sorry about that :p

> Did you try my steps? If they work, it would save you a few hops. An image is 
> a Bitmap so converting to ByteArray should be single method calls and not a 
> lot of work.

You mentioned loadBytes() the byteArray the other side. Could you show how to 
do that? If I did it through a SWFLoader I obviously get a security violation. 
That was through the content.loader is that right?

I am about to make a UI component which I will pass a URL to that should take 
care of the rest, but would be good to perfect it if possible.

Are there any size limitations I should know about with ByteArrays? I don't 
want to find out it's all in vain :( I managed to break FlexBuilder when it was 
tracing out the byte array after I had turned it into a string :p

Thanks Alex

Rob

Reply via email to