當前位置: 首頁>>代碼示例>>Java>>正文


Java ExifInterface類代碼示例

本文整理匯總了Java中android.media.ExifInterface的典型用法代碼示例。如果您正苦於以下問題:Java ExifInterface類的具體用法?Java ExifInterface怎麽用?Java ExifInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ExifInterface類屬於android.media包,在下文中一共展示了ExifInterface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readPictureDegree

import android.media.ExifInterface; //導入依賴的package包/類
/**
 * 讀取圖片屬性:旋轉的角度
 * @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;
}
 
開發者ID:StickyTolt,項目名稱:ForeverLibrary,代碼行數:27,代碼來源:Utils.java

示例2: getRotateDegree

import android.media.ExifInterface; //導入依賴的package包/類
/**
 * 獲取圖片旋轉角度
 *
 * @param filePath 文件路徑
 * @return 旋轉角度
 */
public static int getRotateDegree(String filePath) {
    int degree = 0;
    try {
        ExifInterface exifInterface = new ExifInterface(filePath);
        int orientation = exifInterface.getAttributeInt(
                ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
            default:
            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;
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:31,代碼來源:ImageUtils.java

示例3: getImageDegrees

import android.media.ExifInterface; //導入依賴的package包/類
public static int getImageDegrees(String pathName) {
    int degrees = 0;
    try {
        ExifInterface exifInterface = new ExifInterface(pathName);
        int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                degrees = 90;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                degrees = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                degrees = 270;
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return degrees;
}
 
開發者ID:Sherchen,項目名稱:AnimationsDemo,代碼行數:23,代碼來源:ImageUtils.java

示例4: readDegree

import android.media.ExifInterface; //導入依賴的package包/類
/**
 * Read the rotation angle of the picture file.
 *
 * @param path image path.
 * @return one of 0, 90, 180, 270.
 */
public static int readDegree(String path) {
    try {
        ExifInterface exifInterface = new ExifInterface(path);
        int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                return 90;
            case ExifInterface.ORIENTATION_ROTATE_180:
                return 180;
            case ExifInterface.ORIENTATION_ROTATE_270:
                return 270;
            default:
                return 0;
        }
    } catch (Exception e) {
        return 0;
    }
}
 
開發者ID:WeiXinqiao,項目名稱:Recognize-it,代碼行數:25,代碼來源:DefaultAlbumLoader.java

示例5: 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

示例6: readRotation

import android.media.ExifInterface; //導入依賴的package包/類
/**
 * Parses the rotation of the JPEG image.
 */
public static int readRotation(String filePath) {
    try {
        ExifInterface exif = new ExifInterface(filePath);
        switch (exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0)) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                return 90;
            case ExifInterface.ORIENTATION_ROTATE_270:
                return 270;
            case ExifInterface.ORIENTATION_ROTATE_180:
                return 180;
            default:
                return 0;
        }
    } catch (IOException e) {
        if (DEBUG) {
            Log.d(TAG, "Error reading file", e);
        }
    }
    return 0;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:24,代碼來源:ExifOrientation.java

示例7: getOrientation

import android.media.ExifInterface; //導入依賴的package包/類
public static int getOrientation(final String imagePath) {
    int rotate = 0;
    try {
        File imageFile = new File(imagePath);
        ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface
                .ORIENTATION_NORMAL);
        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_270:
                rotate = 270;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                rotate = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_90:
                rotate = 90;
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return rotate;
}
 
開發者ID:viseator,項目名稱:MontageCam,代碼行數:24,代碼來源:BitmapUtils.java

示例8: extractExifInfo

import android.media.ExifInterface; //導入依賴的package包/類
public static void extractExifInfo(MediaDetails details, String filePath) {
    try {
        ExifInterface exif = new ExifInterface(filePath);
        setExifData(details, exif, ExifInterface.TAG_FLASH, MediaDetails.INDEX_FLASH);
        setExifData(details, exif, ExifInterface.TAG_IMAGE_WIDTH, MediaDetails.INDEX_WIDTH);
        setExifData(details, exif, ExifInterface.TAG_IMAGE_LENGTH,
                MediaDetails.INDEX_HEIGHT);
        setExifData(details, exif, ExifInterface.TAG_MAKE, MediaDetails.INDEX_MAKE);
        setExifData(details, exif, ExifInterface.TAG_MODEL, MediaDetails.INDEX_MODEL);
        setExifData(details, exif, ExifInterface.TAG_APERTURE, MediaDetails.INDEX_APERTURE);
        setExifData(details, exif, ExifInterface.TAG_ISO, MediaDetails.INDEX_ISO);
        setExifData(details, exif, ExifInterface.TAG_WHITE_BALANCE,
                MediaDetails.INDEX_WHITE_BALANCE);
        setExifData(details, exif, ExifInterface.TAG_EXPOSURE_TIME,
                MediaDetails.INDEX_EXPOSURE_TIME);
        double data = exif.getAttributeDouble(ExifInterface.TAG_FOCAL_LENGTH, 0);
        if (data != 0f) {
            details.addDetail(MediaDetails.INDEX_FOCAL_LENGTH, data);
            details.setUnit(MediaDetails.INDEX_FOCAL_LENGTH, R.string.unit_mm);
        }
    } catch (IOException ex) {
        // ignore it.
        Log.w(TAG, "", ex);
    }
}
 
開發者ID:mayurkaul,項目名稱:medialibrary,代碼行數:26,代碼來源:MediaDetails.java

示例9: getRotateDegree

import android.media.ExifInterface; //導入依賴的package包/類
static int getRotateDegree(String path) {
    int result = 0;
    try {
        ExifInterface exif = new ExifInterface(path);
        int orientation = exif.getAttributeInt(
                ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                result = 90;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                result = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                result = 270;
                break;
        }
    } catch (IOException ignore) {
        return 0;
    }
    return result;
}
 
開發者ID:Bilibili,項目名稱:boxing,代碼行數:24,代碼來源:BoxingExifHelper.java

示例10: onDecodeOriginal

import android.media.ExifInterface; //導入依賴的package包/類
@Override
public Bitmap onDecodeOriginal(ThreadPool.JobContext jc, final int type) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    int targetSize = MediaItem.getTargetSize(type);

    // try to decode from JPEG EXIF
    if (type == MediaItem.TYPE_MICROTHUMBNAIL) {
        byte[] thumbData = null;
        try {
            ExifInterface exif = new ExifInterface(mLocalFilePath);
            thumbData = exif.getThumbnail();
        } catch (IOException e) {
            Log.w(TAG, "failed to find file to read thumbnail: " + mLocalFilePath);
        }
        if (thumbData != null) {
            Bitmap bitmap = DecodeUtils.decodeIfBigEnough(
                    jc, thumbData, options, targetSize);
            if (bitmap != null) return bitmap;
        }
    }

    return DecodeUtils.decodeThumbnail(jc, mLocalFilePath, options, targetSize, type);
}
 
開發者ID:mayurkaul,項目名稱:medialibrary,代碼行數:25,代碼來源:LocalImage.java

示例11: getRotateDegrees

import android.media.ExifInterface; //導入依賴的package包/類
/**
 * 獲取圖片的旋轉角度
 *
 * @param imgPath 圖片路徑
 * @return 0,90,180,270
 */
public static int getRotateDegrees(String imgPath) {
    int degrees = 0;
    try {
        ExifInterface exif = new ExifInterface(imgPath);
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

        switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                degrees = 90;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                degrees = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                degrees = 270;
                break;
            default:
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return degrees;
}
 
開發者ID:sundevin,項目名稱:utilsLibrary,代碼行數:32,代碼來源:BitmapUtils.java

示例12: getPictureDegree

import android.media.ExifInterface; //導入依賴的package包/類
/**
 * 獲取圖片的旋轉角度
 * http://www.eoeandroid.com/thread-196978-1-1.html
 * @param path 照片路徑
 * @return
 */
public static int getPictureDegree(String path) {
	int degree = 0;
	try {
		// 從指定路徑下讀取圖片,並獲取其EXIF信息
		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;

}
 
開發者ID:CoderCF,項目名稱:TakePhoto,代碼行數:31,代碼來源:FileUtil.java

示例13: getExifRotation

import android.media.ExifInterface; //導入依賴的package包/類
public static int getExifRotation(File imageFile) {
    if (imageFile == null) return 0;
    try {
        ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
        // We only recognize a subset of orientation tag values
        switch (exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED)) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                return 90;
            case ExifInterface.ORIENTATION_ROTATE_180:
                return 180;
            case ExifInterface.ORIENTATION_ROTATE_270:
                return 270;
            default:
                return ExifInterface.ORIENTATION_UNDEFINED;
        }
    } catch (IOException e) {
        return 0;
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:CropUtil.java

示例14: getExifRotateDegrees

import android.media.ExifInterface; //導入依賴的package包/類
private static int getExifRotateDegrees(int exifOrientation) {
    int degrees = 0;
    switch (exifOrientation) {
        case ExifInterface.ORIENTATION_NORMAL:
            degrees = 0;
            break;
        case ExifInterface.ORIENTATION_ROTATE_90:
            degrees = 90;
            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            degrees = 180;
            break;
        case ExifInterface.ORIENTATION_ROTATE_270:
            degrees = 270;
            break;
    }
    return degrees;
}
 
開發者ID:zhouzhuo810,項目名稱:CameraCardCropDemo,代碼行數:19,代碼來源:BitmapUtils.java

示例15: rotate

import android.media.ExifInterface; //導入依賴的package包/類
@Override
public void rotate(int degrees) throws Exception {
    GalleryUtils.assertNotInRenderThread();
    Uri baseUri = Images.Media.EXTERNAL_CONTENT_URI;
    ContentValues values = new ContentValues();
    int rotation = (this.rotation + degrees) % 360;
    if (rotation < 0) rotation += 360;

    if (mimeType.equalsIgnoreCase("image/jpeg")) {
        ExifInterface exifInterface = new ExifInterface(filePath);
        exifInterface.setAttribute(ExifInterface.TAG_ORIENTATION,
                String.valueOf(rotation));
        exifInterface.saveAttributes();
        fileSize = new File(filePath).length();
        values.put(Images.Media.SIZE, fileSize);
    }

    values.put(Images.Media.ORIENTATION, rotation);
    mApplication.getContentResolver().update(baseUri, values, "_id=?",
            new String[]{String.valueOf(id)});
}
 
開發者ID:mayurkaul,項目名稱:medialibrary,代碼行數:22,代碼來源:LocalImage.java


注:本文中的android.media.ExifInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。