Return to Snippet

Revision: 10354
at December 21, 2008 21:05 by dain


Updated Code
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); 
	 } ) 
 } )

Revision: 10353
at December 21, 2008 21:03 by dain


Initial Code

                                

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

Initial Description
Resizes BitmapData objects smoothly, using bilinear algorithm.

Initial Title
Smooth bitmap resize

Initial Tags
resize, textmate, flash

Initial Language
ActionScript 3