BitmapData.draw() is limited to 4096px
December 11th, 2008 • AIR, ActionScript, Flash
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)
-
-
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
-
Thanks for your reply Martin! The code tweaks olivier made worked out perfect!
By the way, thanks for releasing such a great class!
Thanks, you just helped me discover that this is a problem in Picnik :(