I knew I had a class I wrote to do this...
If you have the large image, get its bitmapData, feed it to this function with 
target's dimensions, and boom...you'll get the resized 'thumbnail' as Bitmap. 
You can also change the return type and return the bitmapData "newBmd" (sorry 
about the formatting)

public function scaleBitmapData(_bmd:BitmapData, targetContainerWidth:Number, 
targetContainerHeight:Number):Bitmap {
//set matrix sx & sy 
var sx:Number = targetContainerWidth / _bmd.width;
var sy:Number = targetContainerHeight / _bmd.height;
                                
//instantiate new matrix, and set scaling
var m:Matrix = new Matrix();
m.scale(sx, sy);
                        
//create new bitmapdata         
var newBmd:BitmapData = new BitmapData(targetContainerWidth, 
targetContainerHeight);
                        
//draw new bitmapdata with matrix       
newBmd.draw(_bmd, m);
                        
//create final bitmap with new bitmapdata
var newBmp:Bitmap = new Bitmap(newBmd);
                        
//set smooting to true
newBmp.smoothing = true;
                        
//boom!
return newBmp;
}

--- In flexcoders@yahoogroups.com, "stinasius" <stinas...@...> wrote:
>
> i just need a way to create a thumbnail from a larger image dynamically in 
> flex so that i dont have to store both a thumb and large image of the same 
> image. trying to save on storage and load time of application. can some one 
> please help out. thanks
>


Reply via email to