bug fix following the recommentation/patch from Alexxey593 with the wrong deletion of the CameraImageWrapper in QZXing.cpp

This commit is contained in:
favoritas37 2015-05-16 17:14:14 +03:00
parent 4c0843478d
commit 0cea1dc288
3 changed files with 13 additions and 60 deletions

View File

@ -69,36 +69,6 @@ unsigned char* CameraImageWrapper::copyMatrix() const
return newMatrix;
}
//bool CameraImageWrapper::setImage(QString fileName, int maxWidth, int maxHeight)
//{
// bool isLoaded = image.load(fileName);
// if(!isLoaded)
// return false;
// width = image.width();
// height = image.height();
// scale(maxWidth, maxHeight);
// return true;
//}
//bool CameraImageWrapper::setImage(QImage newImage, int maxWidth, int maxHeight)
//{
// if(newImage.isNull())
// return false;
// image = newImage.copy();
// width = image.width();
// height = image.height();
// scale(maxWidth, maxHeight);
// return true;
//}
QImage CameraImageWrapper::grayScaleImage(QImage::Format f)
{
QImage tmp(image.width(), image.height(), f);
@ -149,37 +119,13 @@ ArrayRef<char> CameraImageWrapper::getMatrix() const
memcpy(m, &tmpRow->values()[0], width);
#endif
m += width * sizeof(unsigned char);
//delete tmpRow;
}
//pMatrix = matrix;
ArrayRef<char> arr = ArrayRef<char>(matrix, width*height);
if(matrix)
delete matrix;
if (matrix) {
delete matrix;
}
return arr;
}
//void CameraImageWrapper::scale(int maxWidth, int maxHeight)
//{
// image = scale_s(image, maxWidth, maxHeight, isSmoothTransformationEnabled);
//}
//QImage CameraImageWrapper::scale_s(const QImage &image, int maxWidth, int maxHeight, bool smoothTransformation)
//{
// QImage transformedImage;
// if((maxWidth != 1 || maxHeight != 1) && (image.width() > maxWidth || image.height() > maxHeight))
// transformedImage = image.scaled(
// maxWidth != -1 ? maxWidth : image.width(),
// maxHeight != -1 ? maxHeight : image.height(),
// Qt::KeepAspectRatio,
// smoothTransformation ? Qt::SmoothTransformation : Qt::FastTransformation);
// else
// transformedImage = image;
// return transformedImage;
//}

View File

@ -58,6 +58,7 @@ public:
typedef unsigned int DecoderFormatType;
QZXing(QObject *parent = NULL);
~QZXing();
QZXing(DecoderFormat decodeHints, QObject *parent = NULL);

View File

@ -27,6 +27,15 @@ QZXing::QZXing(QObject *parent) : QObject(parent)
imageHandler = new ImageHandler();
}
QZXing::~QZXing()
{
if (imageHandler)
delete imageHandler;
if (decoder)
delete decoder;
}
QZXing::QZXing(QZXing::DecoderFormat decodeHints, QObject *parent) : QObject(parent)
{
decoder = new MultiFormatReader();
@ -131,7 +140,6 @@ QString QZXing::decodeImage(QImage &image, int maxWidth, int maxHeight, bool smo
QString string = QString(res->getText()->getText().c_str());
processingTime = t.elapsed();
qDebug() << "Deconding succeeded: " << string;
delete ciw;
emit tagFound(string);
emit decodingFinished(true);
return string;
@ -140,8 +148,6 @@ QString QZXing::decodeImage(QImage &image, int maxWidth, int maxHeight, bool smo
{
qDebug() << "Deconding failed";
emit decodingFinished(false);
if (ciw)
delete ciw;
processingTime = -1;
return "";
}