mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-12-14 10:29:31 +01:00
Fix reading reverse color qr code
This commit is contained in:
parent
96533f6c2a
commit
dcf7b7854f
@ -38,7 +38,6 @@ import com.google.zxing.PlanarYUVLuminanceSource;
|
||||
import com.google.zxing.RGBLuminanceSource;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.common.GlobalHistogramBinarizer;
|
||||
import com.google.zxing.common.HybridBinarizer;
|
||||
import com.google.zxing.qrcode.QRCodeReader;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
@ -670,7 +669,15 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
|
||||
} else {
|
||||
source = new PlanarYUVLuminanceSource(data, size.getWidth(), size.getHeight(), x, y, side, side, false);
|
||||
}
|
||||
Result result = qrReader.decode(new BinaryBitmap(new GlobalHistogramBinarizer(source)));
|
||||
Result result = null;
|
||||
try {
|
||||
result = qrReader.decode(new BinaryBitmap(new GlobalHistogramBinarizer(source)));
|
||||
} catch (NotFoundException e) {
|
||||
try {
|
||||
result = qrReader.decode(new BinaryBitmap(new GlobalHistogramBinarizer(source.invert())));
|
||||
} catch (NotFoundException ignore) {
|
||||
}
|
||||
}
|
||||
if (result == null) {
|
||||
onNoQrFound();
|
||||
return null;
|
||||
|
@ -596,9 +596,15 @@ object ProxyUtil {
|
||||
|
||||
try {
|
||||
|
||||
val result = qrReader.decode(BinaryBitmap(GlobalHistogramBinarizer(source)), mapOf(
|
||||
DecodeHintType.TRY_HARDER to true
|
||||
))
|
||||
val result = try {
|
||||
qrReader.decode(BinaryBitmap(GlobalHistogramBinarizer(source)), mapOf(
|
||||
DecodeHintType.TRY_HARDER to true
|
||||
))
|
||||
} catch (e: NotFoundException) {
|
||||
qrReader.decode(BinaryBitmap(GlobalHistogramBinarizer(source.invert())), mapOf(
|
||||
DecodeHintType.TRY_HARDER to true
|
||||
))
|
||||
}
|
||||
|
||||
showLinkAlert(ctx, result.text)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user