How can i rotate image and video if it was captured in landscape mode?

随声附和 提交于 2019-12-13 07:14:34

问题


  • 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!