views:

50

answers:

1

I need to load a very big image on AS3 (currently sized at 8192x8192). I am aware that it does not fit any of the limits imposed by Flash regarding drawing to screen or creating a BitmapData of that size. I just want to load the image so I can copyPixels() some parts of it here and there.

The thing is, I'm loading the .jpg file of that size with no problems. The size is recognized correctly from my Loader object. I load it like this:

mImageLoader = new Loader();
var anImageURLRequest:URLRequest = new URLRequest("8192x8192.jpg");
mImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
mImageLoader.load(anImageURLRequest);

Then, on the onComplete method, I try to do this:

Bitmap(mImageLoader.content).bitmapData.getPixel(1000, 1000);

But I am greeted with the #2015 "Invalid BitmapData" error usually reserved for BitmapDatas that are too big. The error also happens if I try to do a copyPixels(), which is what I need to do.

Is there any workaround I can use so I can get data from an image this big on AS3?

+1  A: 

Unfortunately there's no way to do this with AS3/FlashPlayer using the standard BitMap classes.

However, you could try bytearray.org's JPEG Decoder to read the file as a raw ByteArray and then determine the pixels you require like that. - I can't guarantee that it'll work with and 8192x8192px image, but it's worth a try, since it's not reliant on the Flash display system.

If you do use this method, remember that the pixels are stored in a single Vector so you'll need to do something like:

var pixel:int = pixels[ ( width * y ) + x ];

To get the pixel you want.

slomojo
Thank you, I'm going to give that a try.
JohnWithoutArms