问题
- I have an ImageView and VideoView on my screen.
- My Activity is always in a portrait mode (and i can't rotate it because of another elements).
How can i rotate image/video if it was captured in landscape mode?
Show like on this image
instead of
回答1:
public Bitmap rotateBitmap(Bitmap source, float angle) {
Matrix matrix = new Matrix();
// Perform matrix rotations/mirrors depending on camera that took the photo
if (cameraCurrentID == Camera.CameraInfo.CAMERA_FACING_FRONT) {
float[] mirrorY = { -1, 0, 0, 0, 1, 0, 0, 0, 1};
Matrix matrixMirrorY = new Matrix();
matrixMirrorY.setValues(mirrorY);
matrix.postConcat(matrixMirrorY);
}
matrix.postRotate(angle);
return Bitmap.createBitmap(source, 0, 0, source.getWidth(),
source.getHeight(), matrix, false);
}
来源:https://stackoverflow.com/questions/38039186/how-can-i-rotate-image-and-video-if-it-was-captured-in-landscape-mode