Example usage for android.media ExifInterface ORIENTATION_NORMAL

List of usage examples for android.media ExifInterface ORIENTATION_NORMAL

Introduction

In this page you can find the example usage for android.media ExifInterface ORIENTATION_NORMAL.

Prototype

int ORIENTATION_NORMAL

To view the source code for android.media ExifInterface ORIENTATION_NORMAL.

Click Source Link

Usage

From source file:Main.java

private static int decodeExifOrientation(int orientation) {
    switch (orientation) {
    case ExifInterface.ORIENTATION_NORMAL:
        orientation = 0;//  w  w  w  . j av  a  2s. c  o m
        break;
    case ExifInterface.ORIENTATION_ROTATE_90:
        orientation = 90;
        break;
    case ExifInterface.ORIENTATION_ROTATE_180:
        orientation = 180;
        break;
    case ExifInterface.ORIENTATION_ROTATE_270:
        orientation = 270;
        break;
    default:
        break;
    }
    return orientation;
}

From source file:Main.java

private static int getExifOrientation(String src) throws Exception {
    ExifInterface exifInterface = new ExifInterface(src);
    return exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
}

From source file:Main.java

public static int getImageOrientation(String uri) throws IOException {
    ExifInterface exif = new ExifInterface(uri);
    int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
    return orientation;
}

From source file:Main.java

public static int readPictureDegree(String path) {
    int degree = 0;
    try {//from w ww  . j a  va2  s  .co  m
        ExifInterface exifInterface = new ExifInterface(path);
        int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_90:
            degree = 90;
            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            degree = 180;
            break;
        case ExifInterface.ORIENTATION_ROTATE_270:
            degree = 270;
            break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return degree;
}

From source file:Main.java

public static Bitmap normalizeExifRotateBitmap(Bitmap bitmap, int orientation) {

    Matrix matrix = new Matrix();
    switch (orientation) {
    case ExifInterface.ORIENTATION_NORMAL:
        return bitmap;
    case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
        matrix.setScale(-1, 1);//from w w  w. j av  a  2 s  .  c  om
        break;
    case ExifInterface.ORIENTATION_ROTATE_180:
        matrix.setRotate(180);
        break;
    case ExifInterface.ORIENTATION_FLIP_VERTICAL:
        matrix.setRotate(180);
        matrix.postScale(-1, 1);
        break;
    case ExifInterface.ORIENTATION_TRANSPOSE:
        matrix.setRotate(90);
        matrix.postScale(-1, 1);
        break;
    case ExifInterface.ORIENTATION_ROTATE_90:
        matrix.setRotate(90);
        break;
    case ExifInterface.ORIENTATION_TRANSVERSE:
        matrix.setRotate(-90);
        matrix.postScale(-1, 1);
        break;
    case ExifInterface.ORIENTATION_ROTATE_270:
        matrix.setRotate(-90);
        break;
    default:
        return bitmap;
    }
    try {
        Bitmap bmRotated = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
                true);
        bitmap.recycle();
        return bmRotated;
    } catch (OutOfMemoryError e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static int getImageOrientation(String uri) {
    if (!new File(uri).exists()) {
        return 0;
    }/* w  w  w . j a va2 s.co m*/
    try {
        ExifInterface exif = new ExifInterface(uri);
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        return orientation;
    } catch (Exception e) {
    }
    return 0;
}

From source file:Main.java

public static int getOrientationFromExif(String imagePath) {
    int orientation = 0;
    try {/*from w  w  w . j  a  v a 2  s.c  om*/
        ExifInterface exif = new ExifInterface(imagePath);
        int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);

        switch (exifOrientation) {
        case ExifInterface.ORIENTATION_ROTATE_270:
            orientation = 270;

            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            orientation = 180;

            break;
        case ExifInterface.ORIENTATION_ROTATE_90:
            orientation = 90;

            break;

        case ExifInterface.ORIENTATION_NORMAL:
            orientation = 0;

            break;
        default:
            break;
        }
    } catch (Exception e) {

    }

    return orientation;
}

From source file:Main.java

public static int getFileExifDegree(String path) {
    try {//from  ww w .ja va  2s . c  om
        ExifInterface exifInterface = new ExifInterface(path);
        int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_90:
            return 90;
        case ExifInterface.ORIENTATION_ROTATE_180:
            return 180;
        case ExifInterface.ORIENTATION_ROTATE_270:
            return 270;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return 0;
}

From source file:Main.java

private static int readPictureDegree(String path) {
    int degree = 0;
    try {/*from   w  w w . jav  a  2  s. c om*/
        ExifInterface exifInterface = new ExifInterface(path);
        int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_90:
            degree = 90;
            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            degree = 180;
            break;
        case ExifInterface.ORIENTATION_ROTATE_270:
            degree = 270;
            break;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return degree;
}

From source file:Main.java

public final static int getDegress(String path) {
    int degree = 0;
    try {/*  w w  w.j a v  a 2  s . c  om*/
        ExifInterface exifInterface = new ExifInterface(path);
        int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_90:
            degree = 90;
            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            degree = 180;
            break;
        case ExifInterface.ORIENTATION_ROTATE_270:
            degree = 270;
            break;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return degree;
}