当前位置: 首页>>代码示例>>Java>>正文


Java ExifInterface.getAttribute方法代码示例

本文整理汇总了Java中android.media.ExifInterface.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java ExifInterface.getAttribute方法的具体用法?Java ExifInterface.getAttribute怎么用?Java ExifInterface.getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.media.ExifInterface的用法示例。


在下文中一共展示了ExifInterface.getAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getImageRotation

import android.media.ExifInterface; //导入方法依赖的package包/类
String getImageRotation(String file)
{
    String rotation = Integer.toString(ExifInterface.ORIENTATION_NORMAL);

    try
    {
        ExifInterface exifData = new ExifInterface(file);
        rotation = exifData.getAttribute(ExifInterface.TAG_ORIENTATION);
    }
    catch(IOException e)
    {
        Log.w(TAG, "Failed to read rotation data on file: " + file);
    }

    Log.d(TAG, "Read orientation from imported file: " + rotation);

    return rotation;
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:19,代码来源:PropertyPicturesActivity.java

示例2: copyExif

import android.media.ExifInterface; //导入方法依赖的package包/类
private static void copyExif(Context context, Uri oldImage, File newFile) throws IOException {
  File oldFile = getFileFromUri(context, oldImage);
  if (oldFile == null) {
    FLog.w(ReactConstants.TAG, "Couldn't get real path for uri: " + oldImage);
    return;
  }

  ExifInterface oldExif = new ExifInterface(oldFile.getAbsolutePath());
  ExifInterface newExif = new ExifInterface(newFile.getAbsolutePath());
  for (String attribute : EXIF_ATTRIBUTES) {
    String value = oldExif.getAttribute(attribute);
    if (value != null) {
      newExif.setAttribute(attribute, value);
    }
  }
  newExif.saveAttributes();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:ImageEditingManager.java

示例3: getRotatedBitMap

import android.media.ExifInterface; //导入方法依赖的package包/类
public static Bitmap getRotatedBitMap(File imageFile) {
    if (imageFile == null || !imageFile.canRead() || !imageFile.exists()) {
        return null;
    }

    Bitmap rotatedBitmap = null;

    try {
        Bitmap srcBitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
        ExifInterface exif = new ExifInterface(imageFile.getName());
        String orientString = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
        int orientation = orientString != null ? Integer.parseInt(orientString) : ExifInterface.ORIENTATION_NORMAL;

        int rotationAngle = 0;
        if (orientation == ExifInterface.ORIENTATION_ROTATE_90) rotationAngle = 90;
        if (orientation == ExifInterface.ORIENTATION_ROTATE_180) rotationAngle = 180;
        if (orientation == ExifInterface.ORIENTATION_ROTATE_270) rotationAngle = 270;

        Matrix matrix = new Matrix();
        matrix.setRotate(rotationAngle, (float) srcBitmap.getWidth() / 2, (float) srcBitmap.getHeight() / 2);
        rotatedBitmap = Bitmap.createBitmap(srcBitmap, 0, 0, srcBitmap.getWidth(), srcBitmap.getHeight(), matrix, true);

    } catch (Exception e) {
        e.printStackTrace();
        CrashlyticsWrapper.log(e);
    }

    return rotatedBitmap;
}
 
开发者ID:hypertrack,项目名称:hypertrack-live-android,代码行数:30,代码来源:ImageUtils.java

示例4: setExifData

import android.media.ExifInterface; //导入方法依赖的package包/类
private static void setExifData(MediaDetails details, ExifInterface exif, String tag,
                                int key) {
    String value = exif.getAttribute(tag);
    if (value != null) {
        if (key == MediaDetails.INDEX_FLASH) {
            MediaDetails.FlashState state = new MediaDetails.FlashState(
                    Integer.valueOf(value.toString()));
            details.addDetail(key, state);
        } else {
            details.addDetail(key, value);
        }
    }
}
 
开发者ID:mayurkaul,项目名称:medialibrary,代码行数:14,代码来源:MediaDetails.java

示例5: getExifOrientation

import android.media.ExifInterface; //导入方法依赖的package包/类
public static String getExifOrientation(String path) {
    try {
        ExifInterface exif = new ExifInterface(path);
        return exif.getAttribute(ExifInterface.TAG_ORIENTATION);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return String.valueOf(ExifInterface.ORIENTATION_UNDEFINED);
}
 
开发者ID:rosberry,项目名称:media-picker-android,代码行数:10,代码来源:ExifUtils.java

示例6: copyExif

import android.media.ExifInterface; //导入方法依赖的package包/类
public static void copyExif(ExifInterface originalExif, int width, int height, String imageOutputPath) {
    String[] attributes = new String[]{
            ExifInterface.TAG_APERTURE,
            ExifInterface.TAG_DATETIME,
            ExifInterface.TAG_DATETIME_DIGITIZED,
            ExifInterface.TAG_EXPOSURE_TIME,
            ExifInterface.TAG_FLASH,
            ExifInterface.TAG_FOCAL_LENGTH,
            ExifInterface.TAG_GPS_ALTITUDE,
            ExifInterface.TAG_GPS_ALTITUDE_REF,
            ExifInterface.TAG_GPS_DATESTAMP,
            ExifInterface.TAG_GPS_LATITUDE,
            ExifInterface.TAG_GPS_LATITUDE_REF,
            ExifInterface.TAG_GPS_LONGITUDE,
            ExifInterface.TAG_GPS_LONGITUDE_REF,
            ExifInterface.TAG_GPS_PROCESSING_METHOD,
            ExifInterface.TAG_GPS_TIMESTAMP,
            ExifInterface.TAG_ISO,
            ExifInterface.TAG_MAKE,
            ExifInterface.TAG_MODEL,
            ExifInterface.TAG_SUBSEC_TIME,
            ExifInterface.TAG_SUBSEC_TIME_DIG,
            ExifInterface.TAG_SUBSEC_TIME_ORIG,
            ExifInterface.TAG_WHITE_BALANCE
    };

    try {
        ExifInterface newExif = new ExifInterface(imageOutputPath);
        String value;
        for (String attribute : attributes) {
            value = originalExif.getAttribute(attribute);
            if (!TextUtils.isEmpty(value)) {
                newExif.setAttribute(attribute, value);
            }
        }
        newExif.setAttribute(ExifInterface.TAG_IMAGE_WIDTH, String.valueOf(width));
        newExif.setAttribute(ExifInterface.TAG_IMAGE_LENGTH, String.valueOf(height));
        newExif.setAttribute(ExifInterface.TAG_ORIENTATION, "0");

        newExif.saveAttributes();

    } catch (IOException e) {
        Log.d(TAG, e.getMessage());
    }
}
 
开发者ID:Alcatraz323,项目名称:MaterialOCR,代码行数:46,代码来源:ImageHeaderParser.java


注:本文中的android.media.ExifInterface.getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。