1.在CameraManager文件中, 方法:getFramingRectInPreview()
改成下邊這個
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;
2.在DecodeHandler文件中舌菜,方法: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;