Example usage for android.media ExifInterface ORIENTATION_ROTATE_180

List of usage examples for android.media ExifInterface ORIENTATION_ROTATE_180

Introduction

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

Prototype

int ORIENTATION_ROTATE_180

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

Click Source Link

Usage

From source file:Main.java

private static int exifToDegrees(int exifOrientation) {
    switch (exifOrientation) {
    case ExifInterface.ORIENTATION_ROTATE_90:
        return 90;
    case ExifInterface.ORIENTATION_ROTATE_180:
        return 180;
    case ExifInterface.ORIENTATION_ROTATE_270:
        return 270;
    default://from w w  w . ja v  a  2  s  .  c  o  m
        return 0;
    }
}

From source file:Main.java

private static int exifToDegrees(int exifOrientation) {
    if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90) {
        return 90;
    } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180) {
        return 180;
    } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270) {
        return 270;
    }/*w w  w  .ja  v  a 2s  . c  o  m*/
    return 0;
}

From source file:Main.java

public static float exifOrientationToDegrees(int exifOrientation) {

    if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90) {

        return 90;

    } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180) {

        return 180;

    } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270) {

        return 270;

    }/*w ww  .j a  va2 s  . co m*/

    return 0;

}

From source file:Main.java

public static float getDegree(int exifOrientation) {
    if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90)
        return 180;
    else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180)
        return 270;
    else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270)
        return 0;

    return 90;//  ww  w .j  a  va 2 s.c  o  m
}

From source file:Main.java

private static float exifOrientationToDegrees(int exifOrientation) {
    float angle;//from www  .  j a va2 s.  c  o m
    switch (exifOrientation) {
    case ExifInterface.ORIENTATION_ROTATE_90:
        angle = 90;
        break;
    case ExifInterface.ORIENTATION_ROTATE_180:
        angle = 180;
        break;
    case ExifInterface.ORIENTATION_ROTATE_270:
        angle = 270;
        break;
    default:
        angle = 0;
        break;
    }
    return angle;
}

From source file:Main.java

private static int decodeExifOrientation(int orientation) {
    switch (orientation) {
    case ExifInterface.ORIENTATION_NORMAL:
        orientation = 0;/*  w ww  .j a  va2s .  co 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

/**
 * Converts the given Exif Orientation to a degree for rotation.
 * //from w  ww.j a v  a  2 s .  c  om
 * @param exifOrientation
 *            the ExifInterface code for the orientation
 * @return the rotation as a <code>float</code>
 */
private static float exifOrientationToDegrees(int exifOrientation) {
    if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90) {
        return 90;
    } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180) {
        return 180;
    } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270) {
        return 270;
    }
    return 0;
}

From source file:Main.java

/**
 * Gets the Amount of Degress of rotation using the exif integer to determine how much
 * we should rotate the image./* ww  w. j  av a2  s. c  om*/
 * @param exifOrientation - the Exif data for Image Orientation
 * @return - how much to rotate in degress
 */
private static int exifToDegrees(int exifOrientation) {
    if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90) {
        return 90;
    } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180) {
        return 180;
    } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270) {
        return 270;
    }
    return 0;
}

From source file:Main.java

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

    switch (orientation) {
    case ExifInterface.ORIENTATION_ROTATE_90: {
        matrix.setRotate(90);/* w w w.  j a  v  a2s. c  o  m*/
        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;
}

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);//  w w w  .  j  a  va 2 s  .c  o  m
        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;
    }
}