diff --git a/binary/Harmattan-Maemo5/libQZXing.so.1 b/binary/Harmattan-Maemo5/libQZXing.so.1 deleted file mode 100644 index 90dc2f3..0000000 Binary files a/binary/Harmattan-Maemo5/libQZXing.so.1 and /dev/null differ diff --git a/binary/Harmattan-Maemo5/libQZXing.so.1.2 b/binary/Harmattan-Maemo5/libQZXing.so.1.2 deleted file mode 100644 index 90dc2f3..0000000 Binary files a/binary/Harmattan-Maemo5/libQZXing.so.1.2 and /dev/null differ diff --git a/binary/Harmattan-Maemo5/libQZXing.so.1.2.0 b/binary/Harmattan-Maemo5/libQZXing.so.1.2.0 deleted file mode 100644 index 90dc2f3..0000000 Binary files a/binary/Harmattan-Maemo5/libQZXing.so.1.2.0 and /dev/null differ diff --git a/source/CameraImageWrapper.cpp b/source/CameraImageWrapper.cpp index a415f2b..61946ab 100644 --- a/source/CameraImageWrapper.cpp +++ b/source/CameraImageWrapper.cpp @@ -2,6 +2,7 @@ #include #include #include +#include CameraImageWrapper::CameraImageWrapper() : LuminanceSource(0,0), isSmoothTransformationEnabled(false) { @@ -63,6 +64,9 @@ bool CameraImageWrapper::setImage(QString fileName, int maxWidth, int maxHeight) scale(maxWidth, maxHeight); + width = image.width(); + height = image.height(); + return true; } @@ -75,6 +79,9 @@ bool CameraImageWrapper::setImage(QImage newImage, int maxWidth, int maxHeight) scale(maxWidth, maxHeight); + width = image.width(); + height = image.height(); + return true; } @@ -143,10 +150,13 @@ void CameraImageWrapper::setSmoothTransformation(bool enable) void CameraImageWrapper::scale(int maxWidth, int maxHeight) { - if((maxWidth != 1 || maxHeight != 1) && (image.width() > maxWidth || image.height() > maxHeight)) + if((maxWidth != -1 || maxHeight != -1) && (image.width() > maxWidth || image.height() > maxHeight)) + { + qDebug() << "Scaling image to: width " << maxWidth << ", " << ", maxHeight: " << maxHeight; image = image.scaled( maxWidth != -1 ? maxWidth : image.width(), maxHeight != -1 ? maxHeight : image.height(), Qt::KeepAspectRatio, isSmoothTransformationEnabled ? Qt::SmoothTransformation : Qt::FastTransformation); + } } diff --git a/source/QZXing.pri b/source/QZXing.pri index 6f69b21..ad21e45 100644 --- a/source/QZXing.pri +++ b/source/QZXing.pri @@ -9,8 +9,6 @@ DEFINES += QZXING_LIBRARY \ INCLUDEPATH += $$PWD \ $$PWD/zxing - -HEADERS += $$PWD/QZXing_global.h \ HEADERS += $$PWD/QZXing_global.h \ $$PWD/CameraImageWrapper.h \ $$PWD/imagehandler.h \ diff --git a/source/qzxing.cpp b/source/qzxing.cpp index 66571c3..05df4f7 100644 --- a/source/qzxing.cpp +++ b/source/qzxing.cpp @@ -115,6 +115,10 @@ QString QZXing::decodeImage(QImage image, int maxWidth, int maxHeight, bool smoo connect(worker, SIGNAL(decodingFinished(bool)), this, SIGNAL(decodingFinished(bool))); connect(worker, SIGNAL(decodingStarted()), this, SIGNAL(decodingStarted())); connect(worker, SIGNAL(tagFound(QString)), this, SIGNAL(tagFound(QString))); + connect(worker, SIGNAL(quitThread()), thread, SLOT(quit())); + //connect(thread, SIGNAL(finished()), worker, SLOT(deleteLater())); + //connect(thread, SIGNAL(finished()), SLOT(deleteLater())); + worker->setData(&processingTime, image, maxWidth, maxHeight, smoothTransformation, decoder, enabledDecoders); worker->moveToThread(thread); @@ -151,12 +155,12 @@ QString QZXing::decodeImage(QImage image, int maxWidth, int maxHeight, bool smoo ciw = new CameraImageWrapper(image); Ref imageRef(ciw); - GlobalHistogramBinarizer* binz = new GlobalHistogramBinarizer(imageRef); + GlobalHistogramBinarizer binz(imageRef); - Ref bz (binz); - BinaryBitmap* bb = new BinaryBitmap(bz); + Ref bz (&binz); + BinaryBitmap bb(bz); - Ref ref(bb); + Ref ref(&bb); res = ((MultiFormatReader*)decoder)->decode(ref, DecodeHints((int)enabledDecoders)); @@ -166,8 +170,6 @@ QString QZXing::decodeImage(QImage image, int maxWidth, int maxHeight, bool smoo emit decodingFinished(true); delete ciw; - delete binz; - delete bb; return string; } diff --git a/source/qzxingworker_p.cpp b/source/qzxingworker_p.cpp index 7054dca..7a78438 100644 --- a/source/qzxingworker_p.cpp +++ b/source/qzxingworker_p.cpp @@ -10,15 +10,18 @@ #include #include +#include + using namespace zxing; QZXingWorker_p::QZXingWorker_p(QObject *parent) : - QObject(parent) + QObject(parent), maxWidth(-1), maxHeight(-1), smoothTransformation(false) { } QString QZXingWorker_p::decode() { + qDebug() << "Entered threaded decoding"; QTime t; t.start(); Ref res; @@ -27,47 +30,47 @@ QString QZXingWorker_p::decode() if(image.isNull()) { emit decodingFinished(false); - *processingTime = -1; + + //*processingTime = -1; + + qDebug() << "Exited threaded decoding, error"; + + emit quitThread(); return ""; } try{ - CameraImageWrapper* ciw; + CameraImageWrapper ciw; - if(maxWidth > 0 || maxHeight > 0) - { - ciw = new CameraImageWrapper(); - ciw->setSmoothTransformation(smoothTransformation); - ciw->setImage(image, maxWidth, maxHeight); - } - else - ciw = new CameraImageWrapper(image); + ciw.setSmoothTransformation(smoothTransformation); + ciw.setImage(image, maxWidth, maxHeight); - Ref imageRef(ciw); - GlobalHistogramBinarizer* binz = new GlobalHistogramBinarizer(imageRef); + Ref imageRef(&ciw); + GlobalHistogramBinarizer binz(imageRef); - Ref bz (binz); - BinaryBitmap* bb = new BinaryBitmap(bz); + Ref bz (&binz); + BinaryBitmap bb(bz); - Ref ref(bb); + Ref ref(&bb); res = ((MultiFormatReader*)decoder)->decode(ref, DecodeHints((int)enabledDecoders)); QString string = QString(res->getText()->getText().c_str()); - *processingTime = t.elapsed(); + // *processingTime = t.elapsed(); emit tagFound(string); emit decodingFinished(true); - delete ciw; - delete binz; - delete bb; - + qDebug() << "Exited threaded decoding"; + emit quitThread(); return string; } catch(zxing::Exception& e) { emit decodingFinished(false); - *processingTime = -1; + // *processingTime = -1; + + qDebug() << "Exited threaded decoding, error"; + emit quitThread(); return ""; } } diff --git a/source/qzxingworker_p.h b/source/qzxingworker_p.h index e69d412..95042bb 100644 --- a/source/qzxingworker_p.h +++ b/source/qzxingworker_p.h @@ -14,6 +14,8 @@ signals: void decodingStarted(); void decodingFinished(bool succeeded); void tagFound(QString tag); + + void quitThread(); public slots: void setData(int* processingTime, QImage image, int maxWidth, int maxHeight, bool smoothTransformation, diff --git a/source/zxing/zxing/LuminanceSource.h b/source/zxing/zxing/LuminanceSource.h index aec23b0..c05c445 100644 --- a/source/zxing/zxing/LuminanceSource.h +++ b/source/zxing/zxing/LuminanceSource.h @@ -27,9 +27,9 @@ namespace zxing { class LuminanceSource : public Counted { - private: - const int width; - const int height; + protected: + int width; + int height; public: LuminanceSource(int width, int height);