Android Bitmap Rotate rotateBitmap(Bitmap input, int degrees)

Here you can find the source of rotateBitmap(Bitmap input, int degrees)

Description

rotate Bitmap

License

Open Source License

Declaration

public static Bitmap rotateBitmap(Bitmap input, int degrees) 

Method Source Code

//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;
    }
}

Related

  1. GetExifOrientation(String filepath)
  2. reflectionFromBitmap(Bitmap originalBitmap, boolean isFuzzy)
  3. rotate(Bitmap bitmap, int angle)
  4. rotate(Bitmap bitmap, int degrees)
  5. rotateBitmap(Bitmap bitmap, float degrees)
  6. rotateBitmapTranslate(Bitmap bitmap, float degrees)
  7. rotateBitmap(Bitmap source, int rotation, boolean recycle)
  8. rotateBitmap(Bitmap b, int degrees)
  9. getRotatedBitmap(Bitmap bitmap, int degrees)