Example usage for org.apache.cordova ExifHelper resetOrientation

List of usage examples for org.apache.cordova ExifHelper resetOrientation

Introduction

In this page you can find the example usage for org.apache.cordova ExifHelper resetOrientation.

Prototype

public void resetOrientation() 

Source Link

Usage

From source file:com.cooee.cordova.plugins.camera.CameraLauncher.java

License:Apache License

private String ouputModifiedBitmap(Bitmap bitmap, Uri uri) throws IOException {
    // Create an ExifHelper to save the exif data that is lost during compression
    String modifiedPath = getTempDirectoryPath() + "/modified.jpg";

    OutputStream os = new FileOutputStream(modifiedPath);
    bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
    os.close();/* w  w  w  . j ava 2 s.c  om*/

    // Some content: URIs do not map to file paths (e.g. picasa).
    String realPath = FileHelper.getRealPath(uri, this.cordova);
    ExifHelper exif = new ExifHelper();
    if (realPath != null && this.encodingType == JPEG) {
        try {
            exif.createInFile(realPath);
            exif.readExifData();
            if (this.correctOrientation && this.orientationCorrected) {
                exif.resetOrientation();
            }
            exif.createOutFile(modifiedPath);
            exif.writeExifData();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return modifiedPath;
}

From source file:com.cooee.cordova.plugins.camera.CameraLauncher.java

License:Apache License

/**
 * Figure out if the bitmap should be rotated. For instance if the picture was taken in portrait
 * mode/* w  ww  .ja  va  2  s.  c o m*/
 *
 * @return rotated bitmap
 */
private Bitmap getRotatedBitmap(int rotate, Bitmap bitmap, ExifHelper exif) {
    Matrix matrix = new Matrix();
    if (rotate == 180) {
        matrix.setRotate(rotate);
    } else {
        matrix.setRotate(rotate, (float) bitmap.getWidth() / 2, (float) bitmap.getHeight() / 2);
    }

    try {
        bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        exif.resetOrientation();
    } catch (OutOfMemoryError oom) {
        // You can run out of memory if the image is very large:
        // http://simonmacdonald.blogspot.ca/2012/07/change-to-camera-code-in-phonegap-190.html
        // If this happens, simply do not rotate the image and return it unmodified.
        // If you do not catch the OutOfMemoryError, the Android app crashes.
    }

    return bitmap;
}

From source file:com.phonegap.customcamera.NativeCameraLauncher.java

License:Apache License

private Bitmap getRotatedBitmap(int rotate, Bitmap bitmap, ExifHelper exif) {
    Matrix matrix = new Matrix();
    matrix.setRotate(rotate);/*w w w  .  j av a2  s  . com*/
    try {
        bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        exif.resetOrientation();
    } catch (OutOfMemoryError oom) {
        // You can run out of memory if the image is very large:
        // http://simonmacdonald.blogspot.ca/2012/07/change-to-camera-code-in-phonegap-190.html
        // If this happens, simply do not rotate the image and return it unmodified.
        // If you do not catch the OutOfMemoryError, the Android app crashes.
    }
    return bitmap;
}

From source file:com.phonegap.plugins.wsiCameraLauncher.WsiCameraLauncher.java

License:Apache License

/**
 * Figure out if the bitmap should be rotated. For instance if the picture
 * was taken in portrait mode// www . j  a  va 2s.c  o m
 * 
 * @param rotate
 * @param bitmap
 * @return rotated bitmap
 */
private Bitmap getRotatedBitmap(int rotate, Bitmap bitmap, ExifHelper exif) {
    Matrix matrix = new Matrix();
    if (rotate == 180) {
        matrix.setRotate(rotate);
    } else {
        matrix.setRotate(rotate, (float) bitmap.getWidth() / 2, (float) bitmap.getHeight() / 2);
    }
    bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    exif.resetOrientation();
    return bitmap;
}