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());
The result of the logs:
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
**Note: gbConstants.dotIndicatorRotationFactor = 1 (I set it to this number to the lowest value for debugging)
Per 1 degree rotation of the image, 2 pixels were added to the width and height each time newBitmap has been created. I’ve browsed other links and questions but none have answered my question so far. I have also tried debugging over and over again to make sure that there are no other methods that reference the variables and objects that would have affected the outcome. Thanks in advance!
The answer is pretty simple.
An image which is rotated by 1° will need more space in width and height.So the outcome is completely correct. Because otherwise the corners of the picture will be cut of.
Just take a piece of paper and rotate it and you will see how the width and height will increase until you reach 45°.
Edit: maybe this helps you: Image changes size as it's rotated. How do I stop this?