當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。