Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Mozilla Public License 

import android.graphics.Bitmap;
import android.graphics.Matrix;

import android.graphics.drawable.BitmapDrawable;

public class Main {
    /**
     * Rotate the image.
     *
     * @param drawable
     */
    public static BitmapDrawable rotateImage(BitmapDrawable drawable, int degree) {
        Bitmap bitmap = drawable.getBitmap();

        Matrix matrix = new Matrix();
        matrix.postRotate(degree);
        Bitmap rotatedBMP = Bitmap.createBitmap(drawable.getBitmap(), 0, 0, bitmap.getWidth(), bitmap.getHeight(),
                matrix, true);
        return new BitmapDrawable(rotatedBMP);
    }
}