Open palanceli opened 6 years ago
这个demo默认是横屏的,不管手机的实际方向如何,预览图总是一幅横向图:
修改Camera2BasicFragment.java中的configureTransform(...)函数,该函数用于设置textureView的变换矩阵,其中就包括旋转,我在源代码的基础上添加了逆时针旋转90°
configureTransform(...)
private void configureTransform(int viewWidth, int viewHeight) { Activity activity = getActivity(); ... int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); Matrix matrix = new Matrix(); ... matrix.postRotate(-90, centerX, centerY); // 改成竖屏显示 mTextureView.setTransform(matrix); }
运行后如下:
这个demo默认是横屏的,不管手机的实际方向如何,预览图总是一幅横向图:![screenshot_1514121480](https://user-images.githubusercontent.com/13184524/34326792-06a92948-e87b-11e7-9bad-d967cdec0629.png)
修改Camera2BasicFragment.java中的
configureTransform(...)
函数,该函数用于设置textureView的变换矩阵,其中就包括旋转,我在源代码的基础上添加了逆时针旋转90°运行后如下:![screenshot_1514121525](https://user-images.githubusercontent.com/13184524/34326817-7d375238-e87b-11e7-929d-337f7a1565ed.png)