Revision: 15815
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 17, 2009 22:32 by arpit
Initial Code
private static const SCALE_DROP:Number = .5; public function resample(bitmapData:BitmapData, newWidth:uint, newHeight:uint):BitmapData { var finalScale:Number = Math.min(newWidth/bitmapData.width, newHeight/bitmapData.height); var finalData:BitmapData = bitmapData; if (finalScale> 1) { finalData = new BitmapData(bitmapData.width*finalScale, bitmapData.height*finalScale, true, 0); finalData.draw(bitmapData, new Matrix(finalScale, 0, 0, finalScale), null, null, null, true); return finalData; } var drop:Number = SCALE_DROP; var initialScale:Number = finalScale; while (initialScale/drop <1) initialScale /= drop; var bd:BitmapData = new BitmapData(Math.ceil(bitmapData.width*initialScale), Math.ceil(bitmapData.height*initialScale)); bd.draw(finalData, new Matrix(initialScale, 0, 0, initialScale), null, null, null, true); finalData = bd; for (var scale:Number = initialScale*drop; Math.round(scale*1000)>= Math.round(finalScale*1000); scale *= drop) { bd = new BitmapData(Math.ceil(bitmapData.width*scale), Math.ceil(bitmapData.height*scale)); bd.draw(finalData, new Matrix(drop, 0, 0, drop), null, null, null, true); finalData = bd; } return finalData; }
Initial URL
http://jacwright.com/blog/221/high-quality-high-performance-thumbnails-in-flash/
Initial Description
Initial Title
High quality, high performance thumbnails
Initial Tags
Initial Language
ActionScript 3