2009-12-09 44 views

回答

6

您可以使用BitmapData.copyPixels()這一點。

//create a rectangle 
var cropRect:Rectangle = new Rectangle(left, top, width, height); 
//create new bitmap data - because BitmapData's width/height are read only 
var bmpData:BitmapData = new BitmapData(cropRect.width, cropRect.height, true); 
bmpData.copyPixels(image.bitmapData, cropRect, new Point(0, 0)); 
//assign the cropped bitmap data to the image. 
image.bitmapData = bmpData; 

copyPixels()method

public function copyPixels(sourceBitmapData:BitmapData, sourceRect:Rectangle, 
    destPoint:Point, alphaBitmapData:BitmapData = null, alphaPoint:Point = null, 
    mergeAlpha:Boolean = false):void 

提供一個快速例程沒有拉伸,旋轉或色彩效果的圖像之間的像素處理。此方法將源圖像的矩形區域複製到目標BitmapData對象的目標點處大小相同的矩形區域。