From cecdbfa320b82b44d918f5588ab9265cbba01091 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 24 Nov 2008 23:14:33 +0000 Subject: [PATCH] Added toBitmapData. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@720 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flash/ImageUtil.as | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/as/com/threerings/flash/ImageUtil.as b/src/as/com/threerings/flash/ImageUtil.as index a990d873..cbfe695a 100644 --- a/src/as/com/threerings/flash/ImageUtil.as +++ b/src/as/com/threerings/flash/ImageUtil.as @@ -67,6 +67,24 @@ public class ImageUtil */ } + /** + * Takes a BitmapData, Bitmap, or Class that will turn into either, and returns + * a reference to the BitmapData, or returns null. + */ + public static function toBitmapData (spec :*) :BitmapData + { + if (spec is Class) { + spec = new (Class(spec))(); + } + if (spec is BitmapData) { + return BitmapData(spec); + } else if (spec is Bitmap) { + return Bitmap(spec).bitmapData; + } else { + return null; + } + } + /** * Create a minimally-sized "error" BitmapData. */