Skip to content

Commit 4817e15

Browse files
committed
解决条形码与预览框的水平倾角超过30%识别不了,感谢群友 alert 的贡献
1 parent 1605649 commit 4817e15

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

QRCodeLibrary/src/main/java/com/zxing/decoding/DecodeHandler.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
package com.zxing.decoding;
18-
import java.util.Hashtable;
1918

2019
import android.os.Bundle;
2120
import android.os.Handler;
@@ -34,6 +33,8 @@
3433
import com.zxing.camera.CameraManager;
3534
import com.zxing.camera.PlanarYUVLuminanceSource;
3635

36+
import java.util.Hashtable;
37+
3738
final class DecodeHandler extends Handler {
3839

3940
private static final String TAG = DecodeHandler.class.getSimpleName();
@@ -85,6 +86,13 @@ private void decode(byte[] data, int width, int height) {
8586
rawResult = multiFormatReader.decodeWithState(bitmap);
8687
} catch (ReaderException re) {
8788
// continue
89+
try { //解决条形码与预览框的水平倾角超过30%识别不了,感谢群友 alert(3339238074) 的贡献
90+
source = CameraManager.get().buildLuminanceSource(data, height, width);
91+
bitmap = new BinaryBitmap(new HybridBinarizer(source));
92+
rawResult = multiFormatReader.decodeWithState(bitmap);
93+
} catch (Exception e) {
94+
multiFormatReader.reset();
95+
}
8896
} finally {
8997
multiFormatReader.reset();
9098
}

0 commit comments

Comments
 (0)