本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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());
}
}