theDeSilva.com Andrew de Silva

Flash Bitmap maximum width and height

August 5th, 2008 · No Comments · Flash

An updated post has been posted , check it out at [Workaround] Flash Bitmap maximum width and height

Recently I was working with a flash image zoom application and realized that after launching the application it kept crashing when it was loading the larger image, I’ve checked every where and nothing seems to be wrong. File name , image size , file location were all correct. After awhile I realized that the maximum width and maximum height of a BitmapData object is 2880 pixels.  The image that I was working with was way more bigger than that.  Anything that has a height and width that is larger than 2880 will cause flash unable to redraw the bitmap.

Here’s what Adobe has to say about the maximum width and height

Note: The maximum dimensions of a bitmap in Flash Player is limited to 2880 pixels in either direction (width or height). If you attempt to create a BitmapData instance that is larger than this restriction, the Bitmap will not be created. This limit is in place to keep people from creating Flash movies that gobble up the client’s RAM. A bitmap that is 2880 x 2880 pixels, will use roughly 32MB of RAM.

Also interestingly enough

An instance of the BitmapData object can eat up the viewer’s memory quickly. Every pixel in a bitmap is stored using 4 bytes of memory (1 byte per color channel ARGB). If you create a bitmap that is 500 x 500 pixels in size, it will take up close to 1MB of RAM. If you don’t need a BitmapData object anymore, then it is good practice to free the memory that the bitmap is using. The BitmapData class has a method that enables you to do just this, the dispose() method.

So the solution to remove unwanted BitmapData object is to use the following

myBitmap.dispose()
Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Reddit
  • Technorati
  • Facebook
  • Google
  • LinkedIn

Tags: ·····