Android examples for Graphics:Bitmap Rotate
rotate Bitmap by direction
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Matrix; public class Main { public static final int ROTATE_LEFT = 0; public static final int ROTATE_RIGHT = 1; public static Bitmap rotateBitmap(Bitmap bm, int direction) { Bitmap returnBm;/* w w w . ja v a 2 s. c om*/ int w = bm.getWidth(); int h = bm.getHeight(); Matrix matrix = new Matrix(); if (direction == ROTATE_LEFT) { matrix.postRotate(-90); } else if (direction == ROTATE_RIGHT) { matrix.postRotate(90); } returnBm = Bitmap.createBitmap(bm, 0, 0, w, h, matrix, true); if (bm != returnBm) { bm.recycle(); } return returnBm; } }