@@ -417,43 +417,34 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
417
417
lastDecodeOperationSucceded_ = true ;
418
418
} catch (zxing::Exception &/* e*/ ){}
419
419
420
- if (!lastDecodeOperationSucceded_)
420
+ if (!lastDecodeOperationSucceded_ && tryHarder_ )
421
421
{
422
422
hints.setTryHarder (true );
423
+ if (hints.containsFormat (BarcodeFormat::UPC_EAN_EXTENSION) &&
424
+ !allowedExtensions_.empty () &&
425
+ !(hints & DecodeHints::PRODUCT_HINT).isEmpty () )
426
+ hints.setAllowedEanExtensions (std::set<int >());
423
427
424
428
try {
425
429
res = decoder->decode (bb, hints);
426
430
processingTime = t.elapsed ();
427
431
lastDecodeOperationSucceded_ = true ;
428
432
} catch (zxing::Exception &/* e*/ ) {}
433
+ }
429
434
430
- if (!lastDecodeOperationSucceded_ &&
431
- hints.containsFormat (BarcodeFormat::UPC_EAN_EXTENSION) &&
432
- !allowedExtensions_.empty () &&
433
- !(hints & DecodeHints::PRODUCT_HINT).isEmpty () ) {
434
- hints.setAllowedEanExtensions (std::set<int >());
435
+ if (!lastDecodeOperationSucceded_&& tryHarder_ && bb->isRotateSupported ()) {
436
+ Ref<BinaryBitmap> bbTmp = bb;
437
+
438
+ for (int i=0 ; (i<3 && !lastDecodeOperationSucceded_); i++) {
439
+ Ref<BinaryBitmap> rotatedImage (bbTmp->rotateCounterClockwise ());
440
+ bbTmp = rotatedImage;
435
441
436
442
try {
437
- res = decoder->decode (bb , hints);
443
+ res = decoder->decode (rotatedImage , hints);
438
444
processingTime = t.elapsed ();
439
445
lastDecodeOperationSucceded_ = true ;
440
446
} catch (zxing::Exception &/* e*/ ) {}
441
447
}
442
-
443
- if (tryHarder_ && bb->isRotateSupported ()) {
444
- Ref<BinaryBitmap> bbTmp = bb;
445
-
446
- for (int i=0 ; (i<3 && !lastDecodeOperationSucceded_); i++) {
447
- Ref<BinaryBitmap> rotatedImage (bbTmp->rotateCounterClockwise ());
448
- bbTmp = rotatedImage;
449
-
450
- try {
451
- res = decoder->decode (rotatedImage, hints);
452
- processingTime = t.elapsed ();
453
- lastDecodeOperationSucceded_ = true ;
454
- } catch (zxing::Exception &/* e*/ ) {}
455
- }
456
- }
457
448
}
458
449
459
450
if (lastDecodeOperationSucceded_) {
@@ -604,11 +595,11 @@ QImage QZXing::encodeData(const QString &data, const QZXingEncoderConfig &encode
604
595
data.toStdWString (),
605
596
encoderConfig.errorCorrectionLevel == EncodeErrorCorrectionLevel_H ?
606
597
qrcode::ErrorCorrectionLevel::H :
607
- (encoderConfig.errorCorrectionLevel == EncodeErrorCorrectionLevel_Q ?
608
- qrcode::ErrorCorrectionLevel::Q :
609
- (encoderConfig.errorCorrectionLevel == EncodeErrorCorrectionLevel_M ?
610
- qrcode::ErrorCorrectionLevel::M :
611
- qrcode::ErrorCorrectionLevel::L)));
598
+ (encoderConfig.errorCorrectionLevel == EncodeErrorCorrectionLevel_Q ?
599
+ qrcode::ErrorCorrectionLevel::Q :
600
+ (encoderConfig.errorCorrectionLevel == EncodeErrorCorrectionLevel_M ?
601
+ qrcode::ErrorCorrectionLevel::M :
602
+ qrcode::ErrorCorrectionLevel::L)));
612
603
613
604
Ref<qrcode::ByteMatrix> bytesRef = barcode->getMatrix ();
614
605
const std::vector< std::vector <zxing::byte> >& bytes = bytesRef->getArray ();
0 commit comments