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