2012-10-22 199 views
1

只是一個快速的我想翻轉圖像垂直和水平。as3 filp位圖縱向和橫向

我的下面的代碼只是垂直做我不對的東西?

var matrix:Matrix = new Matrix(); 
matrix.scale(1,-1); 
matrix.translate(0,bitmapData.height); 

var flipHorizontalMatrix:Matrix = new Matrix(); 
flipHorizontalMatrix.scale(-1,1); 
flipHorizontalMatrix.translate(bitmapData.width,0); 

bitmapData.draw(loaderInfo.loader, matrix); 


var image:Bitmap = new Bitmap(bitmapData); 
image.width = 1024; 
image.height = 702; 
Bitmap(image).smoothing = true; 

回答

3

爲什麼不嘗試更簡單的方法:

// Reverse the X and Y scale, flipping the image along both axis. 
image.scaleX = image.scaleY = -1; 
+0

給位圖馬蒂? – Bruce

+0

@ bluebill1049是的,'圖像'在我的回答中引用了與您的問題相同的對象,因此位圖。 – Marty

+1

真的很簡單,謝謝馬蒂你總是那麼樂於助人! – Bruce

2

如果你想矩陣時,下面的代碼工作。剛剛測試過:)

var matrix:Matrix = new Matrix(); 
matrix.scale(1,-1); 
matrix.scale(-1,1); 
matrix.translate(0,bitmapData.height); 
matrix.translate(bitmapData.width,0); 

bitmapData.draw(loaderInfo.loader, matrix); 


var image:Bitmap = new Bitmap(bitmapData); 
image.width = 1024; 
image.height = 702; 
Bitmap(image).smoothing = true;