OverlayObject overlayObject = overlayObjects.get(index);
Bitmap dotIndicator = overlayObject.DTO.dotIndicatorBitmap;
int width = dotIndicator.getWidth();
int height = dotIndicator.getHeight();
Log.d("dotIndicator.getWidth()", "" + width);
Log.d("dotIndicator.getHeight()", "" + height);
Matrix matrix = new Matrix();
matrix.postRotate(gbConstants.dotIndicatorRotationFactor, width/2, height/2);
Bitmap newBitmap = Bitmap.createBitmap(dotIndicator, 0, 0,
width, width, matrix, true);
Log.d("newBitmap.getWidth()", "" + newBitmap.getWidth());
Log.d("newBitmap.getHeight()", "" + newBitmap.getHeight());
日誌的結果:)d/dotIndicator.getWidth((20739):: 01-15 14:46:16.485 102 01-15 14:46:16.485:D/newBitmap.getWidth()(20739):104 01-15 14:46:16.485:D/dotIndicator.getHeight()(20739):102 01: d/newBitmap.getHeight()(20739):104機器人Matrix.postRotate()方法使圖像尺寸大
01-15 14:46:16.555: D/dotIndicator.getWidth()(20739): 104
01-15 14:46:16.555: D/dotIndicator.getHeight()(20739): 104
01-15 14:46:16.555: D/newBitmap.getWidth()(20739): 106
01-15 14:46:16.555: D/newBitmap.getHeight()(20739): 106
**注:gbConstants.dotIndicatorRotationFactor = 1(I將其設置爲這個號碼,以用於調試的最低值)
每創建一次newBitmap,圖像每旋轉1度,就會在寬度和高度上添加2個像素。我瀏覽過其他鏈接和問題,但迄今爲止還沒有人回答我的問題。我也一遍又一遍地嘗試調試,以確保沒有其他方法引用會影響結果的變量和對象。提前致謝!
感謝您的回答。我會試試看。這實際上是我的第一個理論,但直到現在我還沒有證實。 – chjarder
這是很久以前的事了,今天我也遇到了同樣的問題。我不得不導致使用形狀和ImageViews而不是手動位圖旋轉 - 非常方便,耗時更少。不管怎麼說,多謝拉。 – chjarder