views:

303

answers:

1

I've got a bare minimum Adobe Air application; it's basically a s:SkinnableContainer inside a mx:WindowedApplication. I have a 6000 x 9000 pixel PNG image (~3.20MB) that I want to show in the SkinnableContainer. Note that the s:SkinnableContainer is a tag from Flex 4 Beta3 (spark components).

Background

Before I explain the problem, a little bit of background on this app. This Air application is supposed to run on the server side, and periodically check a database and read XML markup that describes graphical content (background, child images, child text nodes etc.) of the SkinnableContainer. This markup actually comes from a Flex web application that is used by end-users to create this graphical content. What this Air application is supposed to do is use really high resolution versions of the images used in the Flex web application, and recreate a high resolution version of the graphical content created by the end-user in the browser. The Air application will eventually write out the contents of the SkinnableContainer as a Bitmap to file.

The reason why we're using an Air application is to ensure 100% consistency in rendering between the smaller version of the graphical content, that gets rendered on the browser, and the high resolution version that the Air application will generate.

Problem

The problem I'm facing is that this 3.20MB image does not appear when it is set as the source of the s:Skin applied to the SkinnableContainer. If I use a smaller version of the image, which has dimensions 3000 x 4500 pixel and is 1.73MB, that gets rendered in the application. I'm running the application in debug mode, and I do not get any exception when the large image fails. Children graphical elements of the SkinnableContainer get rendered fine in both cases.

More implementation notes:

  • The source of the skin is a URL to the image, currently, http://localhost/foo/bar.png. I can access the image just fine by hitting it from Firefox.
  • I set the source as follows: BitmapImage([get the skin].backgroundImage).source = "http://localhost/foo/bar.png";

Is there a memory limit that I should be aware of that is enforced by Air? Is this a bug in one of the spark components? Why don't I get any exception? Most importantly, how do I fix this?

+1  A: 

There's an internal limit on how big BitmapData objects can be, presumably due to how it allocates memory for them, so I'm guessing that loaded images also bump into that. See here for details on the limit.

As for fixing it, I think the most straightforward thing to do would be to read and write the beast as a number of sub-images - split into thirds or fourths, since halves would still be over the limit.

fenomas
Yep, that's exactly what I did. I split up the image into tiles and output those. Thanks for the link, I had come across the same page myself :)
Jaffer