Right now, im not entirely worried about my AS-C wrappers. As stated, it's the AS that is causing the chaos.
in AS
myOriginalImg.source = event.target.data; //myOriginalImg is
var loader:Loader = new Loader();
loader.loadBytes(event.target.data);
var bmpData:BitmapData = new BitmapData(myOriginalImg.width, myOriginalImg.height, true, 0x00000000);
bmpData.draw(myOriginalImg);
With the above code, if you output the values of each pixel, you will get 0x00000000 or 0.
I have tested a few more ways, almost all of them printed a blank image.
SO I AM SO SO STUCK AT THIS!!! If you know to turn
###############################################
THANKS TO AH WAI, THE PROBLEM IS SOLVED!
private function ...... :void{
AhWaiGehLoader = new Loader();
AhWaiGehLoader.loadBytes(event.target.data);
AhWaiGehLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderInfoComplete);
...
}
private function onLoaderInfoComplete(event:Event):void
{
var bmpData:BitmapData = Bitmap(AhWaiGehLoader.content).bitmapData; // Ah Wai's one liner solution
var byteArray:ByteArray = bmpData.getPixels(new Rectangle(0,0, myOriginalImg.width, myOriginalImg.height)); // continue with the usual implementation!!
...
}
No comments:
Post a Comment