Below is a function in a class for saving a graphic from flash to a file on a server (using amfphp for the file stuff).
…I found it at http://www.5etdemi.com/blog/archives/2006/10/the-ultimate-as2-bitmapdata-saving-solution/# where it has been discussed somewhat and optimized beyond my level.
I’ve got it working great, and I know it wasn’t made intending to transfer large images, but that’s exactly what I’m doing… huge images for print.
I’ve tested it a bunch and works great even at size 2560 x 1024px… However my largest format is 3639 x 5316 px… and testing at that size fails. I’ve done a lot of digging and tracing but what it comes down to is right here in the beginning where it copies the loaded bitmap into a new BitmapData object… It traces:
*** [onExport] bmp: [object Object] size: 3639,5316
*** [onExport] bmp2: undefined size: undefined,undefined
function onExport()
{
var bmp:BitmapData = BitmapData.loadBitmap('photo_huge');
var bmp2:BitmapData = new BitmapData(bmp.width, bmp.height, true, 0xffffff);
bmp2.draw(bmp);
trace("
*** [onExport] bmp: " + bmp + " size: " + bmp.width + "," + bmp.height);
trace("*** [onExport] bmp2: " + bmp2 + " size: " + bmp2.width + "," + bmp2.height);
_root.attachBitmap(bmp, 0);
this.exp = new BitmapDataSaver('http://www.dev.skinit.com/sean/amfphp/gateway.php', 'BitmapDataSaver');
this.exp.addEventListener('progress', Delegate.create(this, onProgress));
this.exp.addEventListener('complete', Delegate.create(this, onComplete));
this.exp.addEventListener('retrieve', Delegate.create(this, onRetrieve));
this.exp.export(bmp2, 32);
}
But as mentioned with smaller images it works fine. After pondering this for hours I thought perhaps it was my computer running out of memory, but I have a gig of ram and half of my pagefile doesn’t even get used… so it doesn’t seem like it, but I’m not sure…
Then I thought maybe there is a data limit for BitmapData, but the first var bmp loads fine… so I don’t think so.
So, I am somewhat stumped. I tried omitting the second var bmp2 and just using the first one, and the values passed thru the rest of the functions fine, but then hung, so it seems that the second variable is necessary, but I’m not an actionscript master so I don’t quite understand why it is needed.
ANY insight or help would be greatly appreciated.
Thanks