Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Bitmap;

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

import android.util.Log;

public class Main {
    public static Bitmap processToteImage(String image_path, Bitmap bm) {
        Bitmap bitmap = null;
        try {
            ExifInterface exif = new ExifInterface(image_path);
            int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
            Log.d("EXIF", "Exif: " + orientation);
            Matrix matrix = new Matrix();
            if (orientation == 6) {
                matrix.postRotate(90);
            } else if (orientation == 3) {
                matrix.postRotate(180);
            } else if (orientation == 8) {
                matrix.postRotate(270);
            }
            bitmap = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true); // rotating
            // bitmap
        } catch (Exception e) {

        }
        return bitmap;
    }
}