mirror of https://github.com/status-im/qzxing.git
bug fix following the recommentation/patch from Alexxey593 with the wrong deletion of the CameraImageWrapper in QZXing.cpp
This commit is contained in:
parent
4c0843478d
commit
0cea1dc288
|
@ -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;
|
||||
//}
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
typedef unsigned int DecoderFormatType;
|
||||
|
||||
QZXing(QObject *parent = NULL);
|
||||
~QZXing();
|
||||
|
||||
QZXing(DecoderFormat decodeHints, QObject *parent = NULL);
|
||||
|
||||
|
|
|
@ -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 "";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue