本文整理汇总了Java中android.media.ExifInterface.ORIENTATION_TRANSPOSE属性的典型用法代码示例。如果您正苦于以下问题:Java ExifInterface.ORIENTATION_TRANSPOSE属性的具体用法?Java ExifInterface.ORIENTATION_TRANSPOSE怎么用?Java ExifInterface.ORIENTATION_TRANSPOSE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.media.ExifInterface
的用法示例。
在下文中一共展示了ExifInterface.ORIENTATION_TRANSPOSE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExifOrientationDegrees
/**
* Get the # of degrees an image must be rotated to match the given exif orientation.
*
* @param exifOrientation The exif orientation [1-8]
* @return the number of degrees to rotate
*/
public static int getExifOrientationDegrees(int exifOrientation) {
final int degreesToRotate;
switch (exifOrientation) {
case ExifInterface.ORIENTATION_TRANSPOSE:
case ExifInterface.ORIENTATION_ROTATE_90:
degreesToRotate = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
degreesToRotate = 180;
break;
case ExifInterface.ORIENTATION_TRANSVERSE:
case ExifInterface.ORIENTATION_ROTATE_270:
degreesToRotate = 270;
break;
default:
degreesToRotate = 0;
break;
}
return degreesToRotate;
}
示例2: isExifOrientationAllowed
/**
* @return true if and only if given value is a valid EXIF orientation
*/
public static boolean isExifOrientationAllowed(int exifOrientation) {
switch (exifOrientation) {
case ExifInterface.ORIENTATION_NORMAL:
case ExifInterface.ORIENTATION_ROTATE_90:
case ExifInterface.ORIENTATION_ROTATE_180:
case ExifInterface.ORIENTATION_ROTATE_270:
case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
case ExifInterface.ORIENTATION_TRANSPOSE:
case ExifInterface.ORIENTATION_TRANSVERSE:
return true;
default:
return false;
}
}
示例3: 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;
}
示例4: initializeMatrixForRotation
static void initializeMatrixForRotation(int exifOrientation, Matrix matrix) {
switch (exifOrientation) {
case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
matrix.setScale(-1, 1);
break;
case ExifInterface.ORIENTATION_ROTATE_180:
matrix.setRotate(180);
break;
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
matrix.setRotate(180);
matrix.postScale(-1, 1);
break;
case ExifInterface.ORIENTATION_TRANSPOSE:
matrix.setRotate(90);
matrix.postScale(-1, 1);
break;
case ExifInterface.ORIENTATION_ROTATE_90:
matrix.setRotate(90);
break;
case ExifInterface.ORIENTATION_TRANSVERSE:
matrix.setRotate(-90);
matrix.postScale(-1, 1);
break;
case ExifInterface.ORIENTATION_ROTATE_270:
matrix.setRotate(-90);
break;
default:
// Do nothing.
}
}
示例5: isExifOrientationRequired
/**
* Returns {@code true} if the given exif orientation indicates that a transformation is necessary
* and {@code false} otherwise.
*/
public static boolean isExifOrientationRequired(int exifOrientation) {
switch (exifOrientation) {
case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
case ExifInterface.ORIENTATION_ROTATE_180:
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
case ExifInterface.ORIENTATION_TRANSPOSE:
case ExifInterface.ORIENTATION_ROTATE_90:
case ExifInterface.ORIENTATION_TRANSVERSE:
case ExifInterface.ORIENTATION_ROTATE_270:
return true;
default:
return false;
}
}
示例6: initializeMatrixForRotation
@VisibleForTesting
static void initializeMatrixForRotation(int exifOrientation, Matrix matrix) {
switch (exifOrientation) {
case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
matrix.setScale(-1, 1);
break;
case ExifInterface.ORIENTATION_ROTATE_180:
matrix.setRotate(180);
break;
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
matrix.setRotate(180);
matrix.postScale(-1, 1);
break;
case ExifInterface.ORIENTATION_TRANSPOSE:
matrix.setRotate(90);
matrix.postScale(-1, 1);
break;
case ExifInterface.ORIENTATION_ROTATE_90:
matrix.setRotate(90);
break;
case ExifInterface.ORIENTATION_TRANSVERSE:
matrix.setRotate(-90);
matrix.postScale(-1, 1);
break;
case ExifInterface.ORIENTATION_ROTATE_270:
matrix.setRotate(-90);
break;
default:
// Do nothing.
}
}
示例7: getWidth
/**
* @return width of the image
*/
@Override
public int getWidth() {
if (mRotationAngle % 180 != 0
|| mExifOrientation == ExifInterface.ORIENTATION_TRANSPOSE
|| mExifOrientation == ExifInterface.ORIENTATION_TRANSVERSE) {
return getBitmapHeight(mBitmap);
}
return getBitmapWidth(mBitmap);
}
示例8: getHeight
/**
* @return height of the image
*/
@Override
public int getHeight() {
if (mRotationAngle % 180 != 0
|| mExifOrientation == ExifInterface.ORIENTATION_TRANSPOSE
|| mExifOrientation == ExifInterface.ORIENTATION_TRANSVERSE) {
return getBitmapWidth(mBitmap);
}
return getBitmapHeight(mBitmap);
}
示例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: getSoftwareNumerator
private static int getSoftwareNumerator(
ImageRequest imageRequest,
EncodedImage encodedImage,
boolean resizingEnabled) {
if (!resizingEnabled) {
return JpegTranscoder.SCALE_DENOMINATOR;
}
final ResizeOptions resizeOptions = imageRequest.getResizeOptions();
if (resizeOptions == null) {
return JpegTranscoder.SCALE_DENOMINATOR;
}
final int rotationAngle = getRotationAngle(imageRequest.getRotationOptions(), encodedImage);
int exifOrientation = ExifInterface.ORIENTATION_UNDEFINED;
if (INVERTED_EXIF_ORIENTATIONS.contains(encodedImage.getExifOrientation())) {
exifOrientation =
getForceRotatedInvertedExifOrientation(imageRequest.getRotationOptions(), encodedImage);
}
final boolean swapDimensions =
rotationAngle == 90
|| rotationAngle == 270
|| exifOrientation == ExifInterface.ORIENTATION_TRANSPOSE
|| exifOrientation == ExifInterface.ORIENTATION_TRANSVERSE;
final int widthAfterRotation = swapDimensions ? encodedImage.getHeight() :
encodedImage.getWidth();
final int heightAfterRotation = swapDimensions ? encodedImage.getWidth() :
encodedImage.getHeight();
float ratio = determineResizeRatio(resizeOptions, widthAfterRotation, heightAfterRotation);
int numerator = roundNumerator(ratio, resizeOptions.roundUpFraction);
if (numerator > MAX_JPEG_SCALE_NUMERATOR) {
return MAX_JPEG_SCALE_NUMERATOR;
}
return (numerator < 1) ? 1 : numerator;
}
示例11: getIntrinsicWidth
@Override
public int getIntrinsicWidth() {
if (mExifOrientation == ExifInterface.ORIENTATION_TRANSPOSE
|| mExifOrientation == ExifInterface.ORIENTATION_TRANSVERSE
|| mRotationAngle % 180 != 0) {
return super.getIntrinsicHeight();
} else {
return super.getIntrinsicWidth();
}
}
示例12: getIntrinsicHeight
@Override
public int getIntrinsicHeight() {
if (mExifOrientation == ExifInterface.ORIENTATION_TRANSPOSE
|| mExifOrientation == ExifInterface.ORIENTATION_TRANSVERSE
|| mRotationAngle % 180 != 0) {
return super.getIntrinsicWidth();
} else {
return super.getIntrinsicHeight();
}
}
示例13: onBoundsChange
@Override
protected void onBoundsChange(Rect bounds) {
Drawable underlyingDrawable = getCurrent();
if (mRotationAngle > 0
|| (mExifOrientation != ExifInterface.ORIENTATION_UNDEFINED
&& mExifOrientation != ExifInterface.ORIENTATION_NORMAL)) {
switch (mExifOrientation) {
case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
mRotationMatrix.setScale(-1, 1);
break;
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
mRotationMatrix.setScale(1, -1);
break;
case ExifInterface.ORIENTATION_TRANSPOSE:
mRotationMatrix.setRotate(270, bounds.centerX(), bounds.centerY());
mRotationMatrix.postScale(1, -1);
break;
case ExifInterface.ORIENTATION_TRANSVERSE:
mRotationMatrix.setRotate(270, bounds.centerX(), bounds.centerY());
mRotationMatrix.postScale(-1, 1);
break;
default:
mRotationMatrix.setRotate(mRotationAngle, bounds.centerX(), bounds.centerY());
break;
}
// Set the rotated bounds on the underlying drawable
mTempMatrix.reset();
mRotationMatrix.invert(mTempMatrix);
mTempRectF.set(bounds);
mTempMatrix.mapRect(mTempRectF);
underlyingDrawable.setBounds(
(int) mTempRectF.left,
(int) mTempRectF.top,
(int) mTempRectF.right,
(int) mTempRectF.bottom);
} else {
underlyingDrawable.setBounds(bounds);
}
}
示例14: exifToTranslation
public static int exifToTranslation(int exifOrientation) {
int translation;
switch (exifOrientation) {
case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
case ExifInterface.ORIENTATION_TRANSPOSE:
case ExifInterface.ORIENTATION_TRANSVERSE:
translation = -1;
break;
default:
translation = 1;
}
return translation;
}
示例15: rotateBitmap
private Bitmap rotateBitmap(Bitmap bitmap, int orientation) {
Matrix matrix = new Matrix();
switch (orientation) {
case ExifInterface.ORIENTATION_NORMAL:
return bitmap;
case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
matrix.setScale(-1, 1);
break;
case ExifInterface.ORIENTATION_ROTATE_180:
matrix.setRotate(180);
break;
case ExifInterface.ORIENTATION_FLIP_VERTICAL:
matrix.setRotate(180);
matrix.postScale(-1, 1);
break;
case ExifInterface.ORIENTATION_TRANSPOSE:
matrix.setRotate(90);
matrix.postScale(-1, 1);
break;
case ExifInterface.ORIENTATION_ROTATE_90:
matrix.setRotate(90);
break;
case ExifInterface.ORIENTATION_TRANSVERSE:
matrix.setRotate(-90);
matrix.postScale(-1, 1);
break;
case ExifInterface.ORIENTATION_ROTATE_270:
matrix.setRotate(-90);
break;
default:
return bitmap;
}
try {
Bitmap bmRotated = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
bitmap.recycle();
return bmRotated;
} catch (OutOfMemoryError ignore) {
return null;
}
}