[flexcoders] cropping image...with Copypixels

2006-10-12 Thread learner



hello ,
Iam trying to do cropping of image which is dynamically assigned to a vbox componentand i have used following Code:var bd : BitmapData = new BitmapData(h,w);var m1 : Matrix = new Matrix();bd.draw
 (target, m1);var puzzlePieceBmp:BitmapData = new BitmapData(target.width,target.height);puzzlePieceBmp.copyPixels(bd, new Rectangle(x1,y1,h,w), new Point(0, 0));imageid.source = puzzlePieceBmp;this is not working properly, The cropped portion is not of desired height and width, Can any body suggest me how the Rectangle parameter works for copypixesl method.
Its been more than 2 days i am working on this part and i tired searching all forum ..reading live docs about copypixelsbut no gain please guide me in this. Or any one can point me to some URL where the cropping in flex is demonstrated.
I would be very gratefulRegardsPS

__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Software development tool
  
  
Software development
  
  
Software development services
  
  


Home design software
  
  
Software development company
  

   
  






  
  Your email settings: Individual Email|Traditional 
  Change settings via the Web (Yahoo! ID required) 
  Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured 
   
Visit Your Group 
   |
  
Yahoo! Groups Terms of Use
   |
  
   Unsubscribe 
   
 

  




__,_._,___



RE: [flexcoders] cropping image...with Copypixels

2006-10-12 Thread Andrew Trice












Instead of using copyPixels, try something
like this This function crops the bitmapData to the width and
height with respect to the center of the image.



public function centerAndCrop( bitmapData :
BitmapData, cWidth : Number, cHeight : Number ) : BitmapData {

 

 if(cWidth 
bitmapData.width) cWidth = bitmapData.width;

 if(cHeight 
bitmapData.height) cHeight = bitmapData.height;

 

 if(cWidth  1 ||
cHeight  1) return bitmapData

 

 var translateMatrix :
Matrix = new Matrix();

 

 var xOffset : Number
= -Math.abs((bitmapData.width - cWidth)/2);

 var yOffset : Number
= -Math.abs((bitmapData.height - cHeight)/2);

 

 translateMatrix.identity();

 translateMatrix.translate(xOffset,
yOffset);

 

 var returnBitmapData
: BitmapData = new BitmapData(cWidth, cHeight, true);

 

 returnBitmapData.draw(bitmapData,
translateMatrix);

 

 return
returnBitmapData;

 

}



Hope that helps.



-Andy





_

Andrew Trice

Cynergy Systems, Inc.

http://www.cynergysystems.com



Blog: http://www.cynergysystems.com/blogs/page/andrewtrice

Email: [EMAIL PROTECTED]

Office: 866-CYNERGY













From:
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of learner
Sent: Thursday, October 12, 2006
3:37 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] cropping
image...with Copypixels













hello ,






Iam trying to do cropping of image which is dynamically assigned to a
vbox component
and i have used following Code:

var bd : BitmapData = new BitmapData(h,w);
var m1 : Matrix = new Matrix();
bd.draw (target, m1);
var puzzlePieceBmp:BitmapData = new BitmapData(target.width,target.height);
puzzlePieceBmp.copyPixels(bd, new Rectangle(x1,y1,h,w), new
Point(0, 0));
imageid.source = puzzlePieceBmp;


this is not working properly, The cropped portion is not of desired height and
width, Can any body suggest me how the Rectangle parameter works for copypixesl
method. 
Its been more than 2 days i am working on this part and i tired searching all
forum ..reading live docs about copypixelsbut no gain 
please guide me in this. Or any one can point me to some URL where the cropping
in flex is demonstrated. 
I would be very grateful
Regards
PS








__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Software development tool
  
  
Software development
  
  
Software development services
  
  


Home design software
  
  
Software development company
  

   
  






  
  Your email settings: Individual Email|Traditional 
  Change settings via the Web (Yahoo! ID required) 
  Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured 
   
Visit Your Group 
   |
  
Yahoo! Groups Terms of Use
   |
  
   Unsubscribe 
   
 

  




__,_._,___