Here you can find the source of rotateBitmap(Bitmap input, int degrees)
public static Bitmap rotateBitmap(Bitmap input, int degrees)
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.RectF; public class Main { public static Bitmap rotateBitmap(Bitmap input, int degrees) { RectF srcRect = new RectF(0, 0, input.getWidth(), input.getHeight()); Matrix matrix = new Matrix(); matrix.setRotate(degrees);// ww w .j a va 2 s .c o m matrix.mapRect(srcRect); matrix.postTranslate(0 - srcRect.left, 0 - srcRect.top); Bitmap targetBitmap = Bitmap.createBitmap( Math.round(srcRect.width()), Math.round(srcRect.height()), Bitmap.Config.RGB_565); Canvas canvas = new Canvas(targetBitmap); canvas.drawBitmap(input, matrix, new Paint()); return targetBitmap; } }