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());
日志结果: 01-15 14:46:16.485: D/dotIndicator.getWidth()(20739): 102 01-15 14:46:16.485: D/dotIndicator.getHeight()(20739): 102 01- 15 14:46:16.485: D/newBitmap.getWidth()(20739): 104 01-15 14:46:16.485: D/newBitmap.getHeight()(20739): 104
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 (我把它设置为这个数字为最低值以便调试)
图像每旋转 1 度,每次创建 newBitmap 时,宽度和高度都会增加 2 个像素。我浏览了其他链接和问题,但到目前为止没有人回答我的问题。我还反复尝试调试,以确保没有其他方法引用会影响结果的变量和对象。提前致谢!