BitmapData.draw() is limited to 4096px

Thanks to Jens I figured out another limitation in the BitmapData class. It’s actually buried in the draw() method which doesn’t copy any pixels to the BitmapData object whose target x-/y-position is greater than 4096px (0×1000). You don’t get any error just the pixels won’t be copied. This behavior is the same in FlashPlayer 9 and 10 and of course AIR 1.0 – 1.5.
Actually this is no problem for the regular use of BitmapData in FP9 because the BitmapData size is limited to 2880×2880px but using my BitmapDataUnlimited Class and trying to snapshot a Sprite wider or higher than 4096px won’t end up in your desired result.
As you probably know Adobe changed the BitmapData limit in FP10 to a more flexible one, so you are not limited by a specific size anymore but a maximum pixel count of 16,777,215. This means that you can have a BitmapData up to 8191×2048px without using BitmapDataUnlimited but interestingly you can’t draw a Sprite with the same size to this BitmapData object. I think Adobe forgot about their own secret, undocumented »feature«.

example

Sprite: w=8191, h=2048

FP10 BitmapData: w=8191, h=2048 with snapshot of the Sprite

workaround

A workaround for that problem would be to draw everything directly to the BitmapData or if you have to snapshot a Sprite greater than 4096px you could draw it to 4096px BitmapData chunks and copy them to the huge BitmapData afterwards using copyPixels().

Update December 14th, 2008

I added a draw method to the BitmapDataUnlimited class to bypass the 4096px limit.



6 Responses (Add Your Comment)

  1. Thanks, you just helped me discover that this is a problem in Picnik :(

  2. Hello,

    I was wondering if its possible to use the BitmapDataUnlimited draw function along with passing it a matrix like the normal BitmapData.draw(). My problem is that I have a matrix that scales and rotates the source. Then I pass this matrix into the bitmapdata.draw function.

    Any help or ideas you have would be greatly appreciated.

    Thanks,

    Ryan

  3. hey ryan, have a look at the BitmapDataUnlimited Post there was a discussion about that already

  4. Thanks for your reply Martin! The code tweaks olivier made worked out perfect!

    By the way, thanks for releasing such a great class!

Trackbacks:

Leave a Reply

Formatting: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Other Entries

About

Martin Rädlinger is an Interactive Developer & Designer. He specializes in interactive coding predominantly with ActionScript, but every new challenge is welcome. If you like his work feel free to get in touch with him. At the moment he's available for freelance work.

Contact

Martin Rädlinger
mail: mr [at] formatlos.de
web: www.formatlos.de
xing: Martin Rädlinger
linkedin: Martin Rädlinger
skype: martinraedlinger