Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.Matrix;
import android.media.ExifInterface;

public class Main {
    public static Bitmap getTotateBitmap(Bitmap bitmap, int orientation) {
        Matrix matrix = new Matrix();

        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_90: {
            matrix.setRotate(90);
            bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        }
            break;
        case ExifInterface.ORIENTATION_ROTATE_180: {
            matrix.setRotate(180);
            bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        }
            break;
        case ExifInterface.ORIENTATION_ROTATE_270: {
            matrix.setRotate(270);
            bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        }
            break;
        default:
            break;
        }
        return bitmap;
    }
}