2010-06-26 28 views
2

我知道如何用drawTexturePath將任意角度的BlackBerry Bitmap圖像旋轉。但是,旋轉錨點位於圖像的左上角。如何將錨點移動到圖像的中心?BlackBerry drawTexturedPath旋轉將錨點移至圖像的中心

該代碼使用Graphics.drawTexturedPath繞左上角旋轉:

int[] x = new int[] {0, width, width, 0}; 
int[] y = new int[] {0, 0, height, height}; 
int angle32 = Fixed32.toFP(angleDegrees); 
int dux = Fixed32.cosd(angle32); 
int dvx = -Fixed32.sind(angle32); 
int duy = Fixed32.sind(angle32);   
int dvy = Fixed32.cosd(angle32);  
graphics.drawTexturedPath(x, y, null, null, 0, 0, dvx, dux, dvy, duy, bitmapImage); 

如何修改這個代碼,以圍繞圖像與drawTexturedPath(http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/ui/Graphics.html#drawTexturedPath)的中心旋轉?如果您有任何疑問,請聯繫我們,我們將盡快與您聯繫。

-Thanks提前,大衛Pixelmonks.com

+0

您能否提供一組圖像示例以更好地說明旋轉行爲? – Zecas 2012-05-31 16:27:35

回答

1

以圍繞中心,你需要旋轉前以取代您的位圖:的 代替

int[] x = new int[] {0, width, width, 0}; 
int[] y = new int[] {0, 0, height, height}; 

你應該使用

int[] x = new int[] {-width/2, width/2, width/2, -width/2}; 
int[] y = new int[] {-height/2, -height/2, height/2, height/2}; 

然後應用轉換,並將width/2再次添加到所有x值,並將height/2再次添加到您的y值。