android 由于识别区太小,以至于近距离不能完全覆盖二维码图标??

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;

你可能感兴趣的:(android 由于识别区太小,以至于近距离不能完全覆盖二维码图标??)