Search in sources :

Example 66 with ExifInterface

use of android.media.ExifInterface in project GalleryFinal by pengjianbo.

the class CropUtil method copyExifRotation.

public static boolean copyExifRotation(File sourceFile, File destFile) {
    if (sourceFile == null || destFile == null)
        return false;
    try {
        ExifInterface exifSource = new ExifInterface(sourceFile.getAbsolutePath());
        ExifInterface exifDest = new ExifInterface(destFile.getAbsolutePath());
        exifDest.setAttribute(ExifInterface.TAG_ORIENTATION, exifSource.getAttribute(ExifInterface.TAG_ORIENTATION));
        exifDest.saveAttributes();
        return true;
    } catch (IOException e) {
        ILogger.e(e);
        return false;
    }
}
Also used : ExifInterface(android.media.ExifInterface) IOException(java.io.IOException)

Example 67 with ExifInterface

use of android.media.ExifInterface in project android_packages_apps_Camera by CyanogenMod.

the class PanoramaModule method savePanorama.

private Uri savePanorama(byte[] jpegData, int width, int height, int orientation) {
    if (jpegData != null) {
        String filename = PanoUtil.createName(mActivity.getResources().getString(R.string.pano_file_name_format), mTimeTaken);
        String filepath = Storage.getStorage().writeFile(filename, jpegData);
        // Add Exif tags.
        try {
            ExifInterface exif = new ExifInterface(filepath);
            exif.setAttribute(ExifInterface.TAG_GPS_DATESTAMP, mGPSDateStampFormat.format(mTimeTaken));
            exif.setAttribute(ExifInterface.TAG_GPS_TIMESTAMP, mGPSTimeStampFormat.format(mTimeTaken));
            exif.setAttribute(ExifInterface.TAG_DATETIME, mDateTimeStampFormat.format(mTimeTaken));
            exif.setAttribute(ExifInterface.TAG_ORIENTATION, getExifOrientation(orientation));
            exif.saveAttributes();
        } catch (IOException e) {
            Log.e(TAG, "Cannot set EXIF for " + filepath, e);
        }
        int jpegLength = (int) (new File(filepath).length());
        return Storage.getStorage().addImage(mContentResolver, filename, mTimeTaken, null, orientation, jpegLength, filepath, width, height);
    }
    return null;
}
Also used : ExifInterface(android.media.ExifInterface) IOException(java.io.IOException) File(java.io.File)

Example 68 with ExifInterface

use of android.media.ExifInterface in project smartmodule by carozhu.

the class Bitmaputil method readPictureDegree.

/**
 * 读取图片属性:旋转的角度
 *
 * @param path 图片绝对路径
 * @return degree旋转的角度
 */
public static int readPictureDegree(String path) {
    int degree = 0;
    try {
        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;
}
Also used : ExifInterface(android.media.ExifInterface) IOException(java.io.IOException) Paint(android.graphics.Paint)

Example 69 with ExifInterface

use of android.media.ExifInterface in project JustAndroid by chinaltz.

the class LubanCompresser method getImageSpinAngle.

/**
 * obtain the image rotation angle
 *
 * @param path path of target image
 */
private int getImageSpinAngle(String path) throws IOException {
    int degree = 0;
    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;
    }
    return degree;
}
Also used : ExifInterface(android.media.ExifInterface)

Example 70 with ExifInterface

use of android.media.ExifInterface in project JustAndroid by chinaltz.

the class PictureFileUtils method readPictureDegree.

/**
 * 读取图片属性:旋转的角度
 *
 * @param path 图片绝对路径
 * @return degree旋转的角度
 */
public static int readPictureDegree(String path) {
    int degree = 0;
    try {
        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;
}
Also used : ExifInterface(android.media.ExifInterface) IOException(java.io.IOException) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Aggregations

ExifInterface (android.media.ExifInterface)153 IOException (java.io.IOException)93 Paint (android.graphics.Paint)32 Bitmap (android.graphics.Bitmap)26 InputStream (java.io.InputStream)21 File (java.io.File)17 BitmapFactory (android.graphics.BitmapFactory)16 Matrix (android.graphics.Matrix)15 FileInputStream (java.io.FileInputStream)15 Point (android.graphics.Point)13 ByteArrayInputStream (java.io.ByteArrayInputStream)12 ErrnoException (android.system.ErrnoException)10 BufferedInputStream (java.io.BufferedInputStream)10 FileDescriptor (java.io.FileDescriptor)10 FileNotFoundException (java.io.FileNotFoundException)10 SuppressLint (android.annotation.SuppressLint)9 FileOutputStream (java.io.FileOutputStream)8 Cursor (android.database.Cursor)7 AssetFileDescriptor (android.content.res.AssetFileDescriptor)6 Bundle (android.os.Bundle)5