Hello, this is my first post here - but after 2days of trying to figure this out I find i’ve come to the end of the road.
Basically, i’m trying to get loader.load to load a bitmap that has a special encoding within. However, when using Loader.load - i’m getting an abnormal BitmapData back, whereas using an “[Embed]” and BitmapAsset - I am getting correct BitmapData.
[Embed(source="fb838b723f4274a145319fd133591865.png")]
private var bitmapImg:Class;
private var tmpAsset:BitmapAsset;
private var img:Bitmap;
private var data:BitmapData;
public function startProcess(hash:String) : void
{
this.hash = "fb838b723f4274a145319fd133591865";
this.loader = new Loader();
this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE, got_banner);
this.loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progress);
this.loader.load(new URLRequest("C:\\Img\\" + this.hash + ".png"));
}
public function got_banner(e:Event) : void
{
//this.data = (e.currentTarget.content).bitmapData;
this.data = new BitmapData(e.currentTarget.content.width, e.currentTarget.content.height, true, 0x00FFFFFF);
this.data.draw(e.currentTarget.content);
trace(this.data.getPixel(60, 90)); // This returns 6898723 - which is incorrect.
this.tmpAsset = new bitmapImg() as BitmapAsset;
var tData:BitmapData = tmpAsset.bitmapData;
trace(tData.getPixel(60,90)); // This returns 6964516 - which is correct
var diff:BitmapData = tData.compare(data) as BitmapData;
var bit:Bitmap = new Bitmap(diff);
addChild(bit);
Does the Loader.load pad/manipulate a PNG in any way? Would it remove the encrypted/encoded message within?
I have tried URLLoader, URLStream etc - all give the same result. I’ve even tried a FileStream within AIR to dynamically read the image.
It’s got to the point where if the image is only going to be able to be decoded by being embedded within a BitmapAsset - i’m going to have to dynamically update the .as file with the filename, and compile using the flex compiler at command-line within my own C# application.
Any help would be greatly appriciated.
P.S I’ve also attached the bitmap image.
Regards,
Mike