Smooth Scaling Bitmaps in Flash with MIP Mapping

Posted by & filed under Flash.

Hopefully you never experience the frustration of trying to explain to a designer/pm/client why an object aliases when it scales in a SWF but not in Photoshop. After all, they don’t want a reason, just a solution. Had I known about MIP Mapping, I could have saved myself from at least a few of those conversations.

I’m hardly the first to post on this topic, but MIP Mapping is a under-appreciated feature of Flash Player that deserves some more attention. I first came across the subject while reading Papervision 3D Essentials. If you find yourself in a situation where you need to scale bitmaps in Flash, you should be aware of MIP Maps. MIP Maps are basically smaller, higher-quality versions of static bitmaps that Flash Player creates at runtime for use in scaling. When an object scales, Flash player gets the two closest-sized bitmaps from the MIP Map and interpolates to create a smoothed image.

This sounds great, but what do developers need to know and do in order to take full advantage of MIP Mapping?

  1. MIP Mapping only works for static bitmaps – don’t waste your time trying to optimize an object for MIP Mapping if the object in question is a MovieClip with cacheAsBitmap set to true or an object with a filter applied.
  2. Start with even dimensions – odd dimension objects never get mapped, so you don’t get benefit from MIP Mapping
  3. Power of two dimensions work best – 2^n is always ideal for MIP Mapping. Keep in mind that your bitmaps don’t have to be square – you can mix and match powers of two for width and height.
  4. Enable smoothing for more improvementBitmap.smoothing = true; will give you additional improvements in scaled quality.
  5. Use MIP Mapping in Papervision – MIP Mapping in Papervision increases performance when BitmapMaterial.AUTO_MIP_MAPPING is set to true.

Happy MIP Mapping!

Leave a Reply

  • (will not be published)

XHTML: 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>