I am trying to let the user import giant images into a flash application.
Unfortunately the BitmapData object's dimensions cannot exceed "8,191 pixels in width or height, and the total number of pixels cannot exceed 16,777,215 pixels" (see Reference)
Obviously with FlashPlayer11 these limitations vanish - BUT: As I only get bytes from the FileReference, I need to convert these via Loader.loadBytes(), to get access to the image data. This doesn't seem to work for images exceeding the old BitmapData limitations.
Does anybody have an idea, what causes this problem / how to work-around?
function onAddButtonClicked(e:MouseEvent = null):void {
trace("Opening file");
_frl = new FileReferenceList();
_frl.addEventListener(Event.SELECT, onFilesSelected);
_frl.browse([new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg;*.jpeg;*.gif;*.png")]);
}
//When user has selected the files
function onFilesSelected(e:Event):void {
for each (var item:FileReference in _frl.fileList) {
item.load();
item.addEventListener(Event.COMPLETE, onFileLoaded);
}
}
//When files are loaded into the application
function onFileLoaded(e:Event):void {
trace("File Loaded!");
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onBytesLoaded);
loader.loadBytes(e.target.data);
}
//When files are finally available as Loader/Image
function onBytesLoaded(e:Event):void {
addChild((e.target as LoaderInfo).loader);
}
In our app, with Flash Player 11.1 r102 this is working ok. I do everything the same as you except for in the onBytesLoaded handler. Try this to see if the bitmap is actually loading. I tested with a 12,000 x 12,000 pixel JPEG (144,000,000 total pixels) which loaded perfectly (besides being terribly slow to load)
function onBytesLoaded(e:Event):void {
var ldr:Loader = Loader(e.target.loader);
var bmp:Bitmap = Bitmap(ldr.content);
trace("Bitmap Loaded: " + bmp.width + "x" + bmp.height);
var img:Image = new Image();
img.source = bmp;
addChild(img);
}