mirror of https://github.com/status-im/qzxing.git
Added decodeImageQML taken from https://github.com/dplanella/qzxing/blob/master/qzxing.cpp. This is to be used in Qt versions 5.0 and above. Code cleanup needs to be done as well as updates to the examples.
This commit is contained in:
parent
84cf4482f2
commit
357b658029
|
@ -87,18 +87,35 @@ public slots:
|
|||
QString decodeImageFromFile(QString imageFilePath, int maxWidth=-1, int maxHeight=-1, bool smoothTransformation = false);
|
||||
|
||||
/**
|
||||
* The decoding function accessible from QML
|
||||
* The decoding function accessible from QML. (Suggested for Qt 4.x)
|
||||
*/
|
||||
QString decodeImageQML(QObject *item);
|
||||
|
||||
/**
|
||||
* The decoding function accessible from QML. Able to set the decoding
|
||||
* of a portion of the image.
|
||||
* of a portion of the image. (Suggested for Qt 4.x)
|
||||
*/
|
||||
QString decodeSubImageQML(QObject* item,
|
||||
const double offsetX = 0 , const double offsetY = 0,
|
||||
const double width = 0, const double height = 0);
|
||||
|
||||
/**
|
||||
* The decoding function accessible from QML. (Suggested for Qt 5.x)
|
||||
* Can be used to decode image from the Camera element preview by providing
|
||||
* the following string: image://camera/preview_1
|
||||
*/
|
||||
QString decodeImageQML(const QUrl &imageUrl);
|
||||
|
||||
/**
|
||||
* The decoding function accessible from QML. Able to set the decoding
|
||||
* of a portion of the image.
|
||||
* Can be used to decode image from the Camera element preview by providing
|
||||
* the following string: image://camera/preview_1
|
||||
* (Suggested for Qt 5.x)
|
||||
*/
|
||||
QString decodeSubImageQML(const QUrl &imageUrl,
|
||||
const double offsetX = 0, const double offsetY = 0,
|
||||
const double width = 0, const double height = 0);
|
||||
/**
|
||||
* Get the prossecing time in millisecond of the last decode operation.
|
||||
* Added mainly as a statistic measure.
|
||||
|
|
|
@ -169,6 +169,29 @@ QString QZXing::decodeSubImageQML(QObject* item,
|
|||
return decodeImage(img);
|
||||
}
|
||||
|
||||
QString QZXing::decodeImageQML(const QUrl &imageUrl)
|
||||
{
|
||||
return decodeSubImageQML(imageUrl);
|
||||
}
|
||||
QString QZXing::decodeSubImageQML(const QUrl &imageUrl,
|
||||
const double offsetX, const double offsetY,
|
||||
const double width, const double height)
|
||||
{
|
||||
QString imagePath = imageUrl.path();
|
||||
imagePath = imagePath.trimmed();
|
||||
QFile file(imagePath);
|
||||
if (!file.exists()) {
|
||||
qDebug() << "[decodeSubImageQML()] The file" << file.fileName() << "does not exist.";
|
||||
emit decodingFinished(false);
|
||||
return "";
|
||||
}
|
||||
QImage img(imageUrl.path());
|
||||
if(!(offsetX == 0 && offsetY == 0 && width == 0 && height == 0)) {
|
||||
img = img.copy(offsetX, offsetY, width, height);
|
||||
}
|
||||
return decodeImage(img);
|
||||
}
|
||||
|
||||
int QZXing::getProcessTimeOfLastDecoding()
|
||||
{
|
||||
return processingTime;
|
||||
|
|
Loading…
Reference in New Issue