[flexcoders] Re: create a thumbnail dynamically from large image using flex

2009-04-18 Thread aphexyuri
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





[flexcoders] Re: create a thumbnail dynamically from large image using flex

2009-04-18 Thread stinasius
hi, please share the whole class please.



[flexcoders] Re: create a thumbnail dynamically from large image using flex

2009-04-18 Thread reygeek
He shared all you need.  Just pass in bitmap data of your image which I believe 
is the source attribute.

var newImg:Image = new Image();
newImg.source = scaleBitmapData(originalImage.source,width,height);

--- In flexcoders@yahoogroups.com, stinasius stinas...@... wrote:

 hi, please share the whole class please.





[flexcoders] Re: create a thumbnail dynamically from large image using flex

2009-04-18 Thread reygeek
Here's another method that would allow you to pass in the whole UIComponent.  
Below is an example usage:

public function getUIComponentBitmapData( target:UIComponent, w:Number, 
h:Number ) : BitmapData
{ 
// scale down (or up)
var scaleX:Number = w / target.width;
var scaleY:Number = h / target.height;
var m:Matrix = new Matrix();
m.scale(scaleX, scaleY);

// get new bitmap data
var bd:BitmapData = new BitmapData( w, h );
bd.draw( target, m );
bd.smoothing = true;

// return the new bitmap data
return bd;  
}



Assume you have var originalImage:Image already set and you want to scale it 
down to 50x30:

var newImage:Image = new Image();
newImage.source = getUIComponentBitmapData( originalImage, 50, 30 );



--- In flexcoders@yahoogroups.com, stinasius stinas...@... wrote:

 hi, please share the whole class please.





[flexcoders] Re: create a thumbnail dynamically from large image using flex

2009-04-17 Thread Bjorn Schultheiss
--- In flexcoders@yahoogroups.com, stinasius stinas...@... wrote:

 any help guys?


http://www.brooksandrus.com/blog/2009/03/11/bilinear-resampling-with-flash-player-and-pixel-bender/



Re: [flexcoders] Re: create a thumbnail dynamically from large image using flex

2009-04-17 Thread dnk

On 16-Apr-09, at 10:59 PM, Bjorn Schultheiss wrote:



 --- In flexcoders@yahoogroups.com, stinasius stinas...@... wrote:
 
  any help guys?
 

 http://www.brooksandrus.com/blog/2009/03/11/bilinear-resampling-with-flash-player-and-pixel-bender/

Just curious, but would the above way be better than say just creating  
a thumbnail with a server side language when you upload or add the  
photo?

I guess in the big picture it really depends on what you are trying to  
accomplish.

d




[flexcoders] Re: create a thumbnail dynamically from large image using flex

2009-04-17 Thread stinasius
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



[flexcoders] Re: create a thumbnail dynamically from large image using flex

2009-04-16 Thread stinasius
any help guys?