@@ -345,7 +345,7 @@ void QZXing::setDecoder(const uint &hint)
345345 * \param bitMatrix
346346 * \return
347347 */
348- QRectF getTagRect (const ArrayRef<Ref< ResultPoint> > &resultPoints, const Ref <BitMatrix> &bitMatrix)
348+ QRectF getTagRect (const QSharedPointer<std::vector<QSharedPointer< ResultPoint>> > &resultPoints, const QSharedPointer <BitMatrix> &bitMatrix)
349349{
350350 if (resultPoints->size () < 2 )
351351 return QRectF ();
@@ -355,15 +355,15 @@ QRectF getTagRect(const ArrayRef<Ref<ResultPoint> > &resultPoints, const Ref<Bit
355355 // 1D barcode
356356 if (resultPoints->size () == 2 ) {
357357 WhiteRectangleDetector detector (bitMatrix);
358- std::vector<Ref <ResultPoint> > resultRectPoints = detector.detect ();
358+ std::vector<QSharedPointer <ResultPoint> > resultRectPoints = detector.detect ();
359359
360360 if (resultRectPoints.size () != 4 )
361361 return QRectF ();
362362
363- qreal xMin = qreal (resultPoints[0 ]->getX ());
363+ qreal xMin = qreal ((* resultPoints) [0 ]->getX ());
364364 qreal xMax = xMin;
365365 for (int i = 1 ; i < resultPoints->size (); ++i) {
366- qreal x = qreal (resultPoints[i]->getX ());
366+ qreal x = qreal ((* resultPoints) [i]->getX ());
367367 if (x < xMin)
368368 xMin = x;
369369 if (x > xMax)
@@ -385,13 +385,13 @@ QRectF getTagRect(const ArrayRef<Ref<ResultPoint> > &resultPoints, const Ref<Bit
385385
386386 // 2D QR code
387387 if (resultPoints->size () == 4 ) {
388- qreal xMin = qreal (resultPoints[0 ]->getX ());
388+ qreal xMin = qreal ((* resultPoints) [0 ]->getX ());
389389 qreal xMax = xMin;
390- qreal yMin = qreal (resultPoints[0 ]->getY ());
390+ qreal yMin = qreal ((* resultPoints) [0 ]->getY ());
391391 qreal yMax = yMin;
392392 for (int i = 1 ; i < resultPoints->size (); ++i) {
393- qreal x = qreal (resultPoints[i]->getX ());
394- qreal y = qreal (resultPoints[i]->getY ());
393+ qreal x = qreal ((* resultPoints) [i]->getX ());
394+ qreal y = qreal ((* resultPoints) [i]->getY ());
395395 if (x < xMin)
396396 xMin = x;
397397 if (x > xMax)
@@ -414,7 +414,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
414414 QElapsedTimer t;
415415 t.start ();
416416 processingTime = -1 ;
417- Ref <Result> res;
417+ QSharedPointer <Result> res;
418418 emit decodingStarted ();
419419
420420 if (image.isNull ())
@@ -425,7 +425,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
425425 return " " ;
426426 }
427427
428- CameraImageWrapper * ciw = ZXING_NULLPTR ;
428+ QSharedPointer< CameraImageWrapper> ciw;
429429
430430 if ((maxWidth > 0 ) || (maxHeight > 0 ))
431431 ciw = CameraImageWrapper::Factory (image, maxWidth, maxHeight, smoothTransformation);
@@ -434,10 +434,10 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
434434
435435 QString errorMessage = " Unknown" ;
436436
437- Ref <LuminanceSource> imageRefOriginal = Ref<LuminanceSource>( ciw) ;
438- Ref <LuminanceSource> imageRef = imageRefOriginal;
439- Ref <GlobalHistogramBinarizer> binz;
440- Ref <BinaryBitmap> bb;
437+ QSharedPointer <LuminanceSource> imageRefOriginal = ciw;
438+ QSharedPointer <LuminanceSource> imageRef = imageRefOriginal;
439+ QSharedPointer <GlobalHistogramBinarizer> binz;
440+ QSharedPointer <BinaryBitmap> bb;
441441
442442 size_t numberOfIterations = 0 ;
443443 if (imageSourceFilter & SourceFilter_ImageNormal)
@@ -451,10 +451,10 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
451451 try {
452452 if ((numberOfIterations == 1 && (imageSourceFilter & SourceFilter_ImageInverted)) || i == 1 ) {
453453 // qDebug() << "Selecting Inverted Luminance source";
454- imageRef = Ref <LuminanceSource>((LuminanceSource*)(new InvertedLuminanceSource (imageRefOriginal)));
454+ imageRef = QSharedPointer <LuminanceSource>((LuminanceSource*)(new InvertedLuminanceSource (imageRefOriginal)));
455455 }
456- binz = Ref <GlobalHistogramBinarizer>( new GlobalHistogramBinarizer (imageRef) );
457- bb = Ref <BinaryBitmap>( new BinaryBitmap (binz) );
456+ binz = QSharedPointer <GlobalHistogramBinarizer>( new GlobalHistogramBinarizer (imageRef) );
457+ bb = QSharedPointer <BinaryBitmap>( new BinaryBitmap (binz) );
458458
459459 DecodeHints hints (static_cast <DecodeHintType>(enabledDecoders));
460460
@@ -493,13 +493,13 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
493493 }
494494
495495 if (!lastDecodeOperationSucceded_&& tryHarder_ && (tryHarderType & TryHarderBehaviour_Rotate) && bb->isRotateSupported ()) {
496- Ref <BinaryBitmap> bbTmp = bb;
496+ QSharedPointer <BinaryBitmap> bbTmp = bb;
497497
498498 // qDebug() << "Decoding phase 2, rotate: starting";
499499
500500 hints.setTryHarder (true );
501501 for (int i=0 ; (i<3 && !lastDecodeOperationSucceded_); i++) {
502- Ref <BinaryBitmap> rotatedImage (bbTmp->rotateCounterClockwise ());
502+ QSharedPointer <BinaryBitmap> rotatedImage (bbTmp->rotateCounterClockwise ());
503503 bbTmp = rotatedImage;
504504
505505 try {
@@ -527,7 +527,6 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
527527 int fmt = res->getBarcodeFormat ().value ;
528528 decodedFormat = decoderFormatToString (1 <<fmt);
529529 charSet_ = QString::fromStdString (res->getCharSet ());
530- qDebug () << " charSet_: " << charSet_;
531530 if (!charSet_.isEmpty ()) {
532531#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
533532 QTextCodec *codec = QTextCodec::codecForName (res->getCharSet ().c_str ());
@@ -670,7 +669,7 @@ QImage QZXing::encodeData(const QString &data, const QZXingEncoderConfig &encode
670669#ifdef ENABLE_ENCODER_QR_CODE
671670 case EncoderFormat_QR_CODE:
672671 {
673- Ref <qrcode::QRCode> barcode = qrcode::Encoder::encode (
672+ QSharedPointer <qrcode::QRCode> barcode = qrcode::Encoder::encode (
674673 data.toStdWString (),
675674 encoderConfig.errorCorrectionLevel == EncodeErrorCorrectionLevel_H ?
676675 qrcode::ErrorCorrectionLevel::H :
@@ -680,7 +679,7 @@ QImage QZXing::encodeData(const QString &data, const QZXingEncoderConfig &encode
680679 qrcode::ErrorCorrectionLevel::M :
681680 qrcode::ErrorCorrectionLevel::L)));
682681
683- Ref <qrcode::ByteMatrix> bytesRef = barcode->getMatrix ();
682+ QSharedPointer <qrcode::ByteMatrix> bytesRef = barcode->getMatrix ();
684683 const std::vector< std::vector <zxing::byte> >& bytes = bytesRef->getArray ();
685684 const int width = int (bytesRef->getWidth ()) + (encoderConfig.border ? 2 : 0 );
686685 const int height = int (bytesRef->getHeight ()) + (encoderConfig.border ? 2 : 0 );
0 commit comments