actionscript-3intbitmapdataflash-player-11

Why can't I have 120,000x120,000 px BitmapData in Flash Player 11 on OS X Lion x64?


Doc says:

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.

But, why can't I have 120,000 x 120,000 px BitmapData object? I'm on OS X Lion with 64 bit kernel.

Now 120,000 ^ 2 would give me 14,400,000,000 pixels I need to occupy, which takes only 34 bits to store that int. But apparently I can have 64 bit integers, no? Do I miss something? And what does it mean "dependent on the operating system"? How?


Solution

  • Since when is a BitmapData pixel equivalent to a single bit? Remember that you are dealing with color information, so each pixel occupies at least a uint(=> size:32 bits, or 4 Bytes).

    Which, then, means that your memory consumption is actually

    120000^2 * 4 => 57,600,000,000 Bytes => ap. 53,6 GB
    

    Also note that while Number is a 64-bit data type, int and uint are not.

    You might want to consider using a different means of organizing your data.
    If you are dealing with a large picture, you have to split it up into parts of reasonable size. The limits may have been lifted, but I would recommend you restrain yourself to max. 4 times the stage size (that's small enough for reasonably smooth scrolling, and large enough so you don't have to place objects on the stage all the time).

    If it is not actual pixel information you want to store, perhaps ByteArray could be a possible alternative.