問題很簡單:我想圍繞某個軸心點旋轉圖像。這裏是我使用的代碼:圍繞樞軸點旋轉圖像
Matrix matrix = new Matrix();
matrix.setTranslate(bmpWidth/2, 0);
matrix.preRotate(degrees, bmpWidth/2, 0);
Bitmap resizedBitmap = Bitmap.createBitmap(
bitmap, 0, 0, bmpWidth, bmpHeight, matrix, true);
ImageView imageView = (ImageView) findViewById(R.id.bell);
imageView.setImageBitmap(resizedBitmap);
我從加速度傳感器得到旋轉角度。其結果是每次圖像圍繞其中心點旋轉。
,但你可能例如,使用'postRotate()'或'setRotate()'來獲得改變變換順序的不同結果。 –
你能給我一個有效的例子嗎?因爲我試圖使用這些方法,但我沒有運氣。謝謝! – Gratzi
我從來沒有使用矩陣變換,所以我不能給你一個例子,但我想我已經閱讀了有關如果沒有以正確的順序應用變換給出意想不到的結果的問題。如果您嘗試在不使用'setTranslate()'的情況下使用* just *'postRotate()',它會起作用嗎? –