In many image related Android applications, we may need to rotate the bitmap(not ImageView). Here I added the code below to rotate the image at any possible angle using Matrix.

Bitmap bInput/*your input bitmap*/, bOutput; float degrees = 45;//rotation degree Matrix matrix = new Matrix(); matrix.setRotate(degrees); bOutput = Bitmap.createBitmap(bInput, 0, 0, bInput.getWidth(), bInput.getHeight(), matrix, true);