/ Published in: ActionScript 3
Resizes BitmapData objects smoothly, using bilinear algorithm.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public static function resampleBitmapData (bmp: BitmapData, ratio: Number): BitmapData ( if (ratio >= 1) { if (ratio> = 1) ( return (BitmapManager.resizeBitmapData(bmp, ratio)); return (BitmapManager.resizeBitmapData (bmp, ratio)); } ) else { else ( var bmpData:BitmapData = bmp.clone(); var bmpData: BitmapData bmp.clone = (); var appliedRatio:Number = 1; var appliedRatio: Number = 1; do { do ( if (ratio < 0.5 * appliedRatio if (ratio <0.5 * appliedRatio ) { ) ( bmpData = BitmapManager.resizeBitmapData(bmpData, 0.5); bmpData = BitmapManager.resizeBitmapData (bmpData, 0.5); appliedRatio = 0.5 * appliedRatio; appliedRatio = 0.5 * appliedRatio; } ) else { else ( bmpData = BitmapManager.resizeBitmapData(bmpData, ratio / appliedRatio); bmpData = BitmapManager.resizeBitmapData (bmpData, ratio / appliedRatio); appliedRatio = ratio; appliedRatio = ratio; } ) } while (appliedRatio != ratio); ) While (appliedRatio! = Ratio); return (bmpData); return (bmpData); } ) } )