本文整理匯總了Java中android.media.ExifInterface.ORIENTATION_ROTATE_180屬性的典型用法代碼示例。如果您正苦於以下問題:Java ExifInterface.ORIENTATION_ROTATE_180屬性的具體用法?Java ExifInterface.ORIENTATION_ROTATE_180怎麽用?Java ExifInterface.ORIENTATION_ROTATE_180使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.media.ExifInterface
的用法示例。
在下文中一共展示了ExifInterface.ORIENTATION_ROTATE_180屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRotateDegree
/**
* 獲取圖片旋轉角度
*
* @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;
}
示例2: getImageDegrees
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;
}
示例3: getBitmapDegree
/**
* 讀取圖片的旋轉的角度
*
* @param path 圖片絕對路徑
* @return 圖片的旋轉角度
*/
public static int getBitmapDegree(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;
}
示例4: readDegree
/**
* 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;
}
}
示例5: exifToDegrees
public static int exifToDegrees(int exifOrientation) {
int rotation;
switch (exifOrientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
case ExifInterface.ORIENTATION_TRANSPOSE:
rotation = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
rotation = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
case ExifInterface.ORIENTATION_TRANSVERSE:
rotation = 270;
break;
default:
rotation = 0;
}
return rotation;
}
示例6: 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;
}
示例7: getPhotoOrientation
@Override
protected int getPhotoOrientation(@CameraConfiguration.SensorPosition int sensorPosition) {
int rotate;
if (currentCameraId.equals(faceFrontCameraId)) {
rotate = (360 + faceFrontCameraOrientation + configurationProvider.getDegrees()) % 360;
} else {
rotate = (360 + faceBackCameraOrientation - configurationProvider.getDegrees()) % 360;
}
if (rotate == 0) {
orientation = ExifInterface.ORIENTATION_NORMAL;
} else if (rotate == 90) {
orientation = ExifInterface.ORIENTATION_ROTATE_90;
} else if (rotate == 180) {
orientation = ExifInterface.ORIENTATION_ROTATE_180;
} else if (rotate == 270) {
orientation = ExifInterface.ORIENTATION_ROTATE_270;
}
return orientation;
}
示例8: getPictureDegree
/**
* 獲取圖片的旋轉角度
* 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;
}
示例9: defineExifOrientation
protected ExifInfo defineExifOrientation(String imageUri) {
int rotation = 0;
boolean flip = false;
try {
ExifInterface exif = new ExifInterface(Scheme.FILE.crop(imageUri));
int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch (exifOrientation) {
case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
flip = true;
case ExifInterface.ORIENTATION_NORMAL:
rotation = 0;
break;
case ExifInterface.ORIENTATION_TRANSVERSE:
flip = true;
case ExifInterface.ORIENTATION_ROTATE_90:
rotation = 90;
break;
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
flip = true;
case ExifInterface.ORIENTATION_ROTATE_180:
rotation = 180;
break;
case ExifInterface.ORIENTATION_TRANSPOSE:
flip = true;
case ExifInterface.ORIENTATION_ROTATE_270:
rotation = 270;
break;
}
} catch (IOException e) {
L.w("Can't read EXIF tags from file [%s]", imageUri);
}
return new ExifInfo(rotation, flip);
}
示例10: getOrientation
public static int getOrientation(String filepath) {
int orientation = ExifInterface.ORIENTATION_NORMAL;
int degree;
try {
ExifInterface exif = new ExifInterface(filepath);
orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
} catch (Exception e) {
e.printStackTrace();
}
switch (orientation) {
case ExifInterface.ORIENTATION_NORMAL:
degree = 0;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
degree = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
degree = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
degree = 270;
break;
default:
degree = 0;
break;
}
return degree;
}
示例11: exifToDegrees
private int exifToDegrees(int exifOrientation) {
if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90) {
return 90;
} else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180) {
return 180;
} else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270) {
return 270;
} else {
return 0;
}
}
示例12: getCameraPhotoOrientation
public static int getCameraPhotoOrientation(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;
}
Log.i("RotateImage", "Exif orientation: " + orientation);
Log.i("RotateImage", "Rotate value: " + rotate);
} catch (Exception e) {
e.printStackTrace();
}
return rotate;
}
示例13: getOrientation
public int getOrientation() {
int o = Integer.parseInt(this.orientation);
if (o == ExifInterface.ORIENTATION_NORMAL) {
return 0;
} else if (o == ExifInterface.ORIENTATION_ROTATE_90) {
return 90;
} else if (o == ExifInterface.ORIENTATION_ROTATE_180) {
return 180;
} else if (o == ExifInterface.ORIENTATION_ROTATE_270) {
return 270;
} else {
return 0;
}
}
示例14: rotateBitmap
/**
* 用於壓縮時旋轉圖片
*
* @throws IOException
* @throws OutOfMemoryError
*/
public static Bitmap rotateBitmap(String srcFilePath, Bitmap bitmap) throws IOException, OutOfMemoryError {
float degree = 0F;
try {
ExifInterface exif = new ExifInterface(srcFilePath);
switch (exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED)) {
case ExifInterface.ORIENTATION_ROTATE_90:
degree = 90F;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
degree = 180F;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
degree = 270F;
break;
default:
break;
}
} catch (IOException e) {
e.printStackTrace();
// 01-23 11:03:04.040 W/ExifInterface(29568): Invalid image.
// 01-23 11:03:04.040 W/ExifInterface(29568): java.io.IOException: Invalid marker: 89
// 01-23 11:03:04.040 W/ExifInterface(29568): at android.media.ExifInterface.getJpegAttributes(ExifInterface.java:1656)
// 01-23 11:03:04.040 W/ExifInterface(29568): at android.media.ExifInterface.loadAttributes(ExifInterface.java:1360)
// 01-23 11:03:04.040 W/ExifInterface(29568): at android.media.ExifInterface.<init>(ExifInterface.java:1064)
}
Matrix matrix = new Matrix();
matrix.setRotate(degree, bitmap.getWidth(), bitmap.getHeight());
Bitmap b2 = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
if (bitmap != b2) {
bitmap.recycle();
bitmap = b2;
}
return bitmap;
}
示例15: getBitmapRotation
private static int getBitmapRotation(String filePath) {
int rotation = 0;
switch (getExifOrientation(filePath)) {
case ExifInterface.ORIENTATION_ROTATE_180:
rotation = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotation = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
rotation = 270;
break;
}
return rotation;
}