Posted By

dain on 12/21/08


Tagged

resize textmate flash bitmapData as3 bitmap


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

THEPWN3R
flashinit
thastyle


Smooth bitmap resize


 / Published in: ActionScript 3
 

URL: http://www.envrac.org/index.php/2008/06/23/181-reduction-de-bitmapdata-smoothing-pourquoi-c-est-pas-beau-et-comment-ameliorer

Resizes BitmapData objects smoothly, using bilinear algorithm.

  1. public static function resampleBitmapData (bmp: BitmapData, ratio: Number): BitmapData (
  2. if (ratio >= 1) { if (ratio> = 1) (
  3. return (BitmapManager.resizeBitmapData(bmp, ratio)); return (BitmapManager.resizeBitmapData (bmp, ratio));
  4. } )
  5. else { else (
  6. var bmpData:BitmapData = bmp.clone(); var bmpData: BitmapData bmp.clone = ();
  7. var appliedRatio:Number = 1; var appliedRatio: Number = 1;
  8.  
  9. do { do (
  10. if (ratio < 0.5 * appliedRatio if (ratio <0.5 * appliedRatio ) { ) (
  11. bmpData = BitmapManager.resizeBitmapData(bmpData, 0.5); bmpData = BitmapManager.resizeBitmapData (bmpData, 0.5);
  12. appliedRatio = 0.5 * appliedRatio; appliedRatio = 0.5 * appliedRatio;
  13. } )
  14. else { else (
  15. bmpData = BitmapManager.resizeBitmapData(bmpData, ratio / appliedRatio); bmpData = BitmapManager.resizeBitmapData (bmpData, ratio / appliedRatio);
  16. appliedRatio = ratio; appliedRatio = ratio;
  17. } )
  18. } while (appliedRatio != ratio); ) While (appliedRatio! = Ratio);
  19.  
  20. return (bmpData); return (bmpData);
  21. } )
  22. } )

Report this snippet  

You need to login to post a comment.