2

I have a big JPEG image file. It's dimension is 19000*14000 and the file size is about 41M. i'm using AIR 3.3 SDK, but after the load completes I can't see the image on stage. Does anyone know what the cause of this issue is?

Here is my code:

protected function button1_clickHandler(event:MouseEvent):void
{
    file = new File();
    file.addEventListener(Event.SELECT, imageFileHandler);
    file.browseForOpen("image file", [new FileFilter("image file","*.jpg;*.jpeg")]);
}

protected function imageFileHandler(event:Event):void
{
    fs = new FileStream();
    fs.openAsync(file, FileMode.READ);
    fs.addEventListener(Event.COMPLETE, bytesComplete);
}

protected function bytesComplete(event:Event):void
{
    loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadHandler);
    var bytes:ByteArray = new ByteArray();
    fs.readBytes(bytes);
    loader.loadBytes(bytes);
    fs.close();
}

protected function imageLoadHandler(event:Event):void
{
    image.source = (loader.content as Bitmap).bitmapData;
}
Ren
  • 1,111
  • 5
  • 15
  • 24
ryanhex53
  • 577
  • 4
  • 15

2 Answers2

1

flash player and air has a limit for image file sizes to display. If i remember right, its 4096*4096. If you want to use a huge image, slice it to more, smaller images, load them separately, and place them one by one. its like you'd want google maps to load the whole earth. it just only loads the visible part. you should consider that as well.

you can also try resizing either the bitmapdata, either the sprite containing it to make the image visible.

csomakk
  • 5,369
  • 1
  • 29
  • 34
  • 16777216 pixels total, 8192 single dimension, to be more precise. – Vesper May 08 '13 at 11:41
  • due to [documentation](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html) from adobe, after air 3, there are no more limit for image dimension. – ryanhex53 May 08 '13 at 14:54
  • 1
    there is still a limit. quote from your link: Starting with AIR 3 and Flash player 11, the size limits for a BitmapData object have been removed. **The maximum size of a bitmap is now dependent on the operating system.** – csomakk May 08 '13 at 15:02
1

I bet your stage is smaller than the actual image. Create a bitmapData that is as big as your stage. use copyPixels of BitmapData to copy the pixels from the big one to the little one (you can decal a x and y position of course).

Make sure you do bitmapData.lock() before the copyPixels is used and unlock() afterwards. These prevent useless updates that WILL cause slowing down, even crashes. copyPixels is a "fat" method :D

This way you don't have to split it in pieces. You can add this update for enterframe or on mousemove.

Discipol
  • 3,137
  • 4
  • 22
  • 41