1. 修改AndroidManifest文件中CaptureActivity对应的属性为:android:screenOrientation="portrait"
android:screenOrientation="portrait"
2. 在DecodeHandler.java文件中的decode函数中,同时在
PlanarYUVLuminanceSource source = activity.getCameraManager().buildLuminanceSource(data, width, height);
之前添加旋转图像的代码如下
byte[] rotatedData = new byte[data.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++)
rotatedData[x * height + height - y - 1] = data[x + y * width];
}
int tmp = width;
width = height;
height = tmp;
data = rotatedData;
3. 在CameraManager.java中修改代码为
//竖屏
rect.left = rect.left * cameraResolution.y / screenResolution.x;
rect.right = rect.right * cameraResolution.y / screenResolution.x;
rect.top = rect.top * cameraResolution.x / screenResolution.y;
rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y;