qzxing icon indicating copy to clipboard operation
qzxing copied to clipboard

Binary data

Open larsfu opened this issue 7 years ago • 4 comments

Hello, thanks for providing this library. I'm using Data Matrix codes containing binary data. Is it somehow possible to get a QByteArray instead of a QString back from decodeImage?

larsfu avatar Mar 04 '18 18:03 larsfu

Hello @Fujnky

after receiving the result from decodeImage that is a QString, can't you just use QString::toLocal8Bit() ?

ftylitak avatar Mar 05 '18 21:03 ftylitak

Unfortunately the string terminates at the first null byte, therefore it's not possible that way.

Am 05.03.2018 10:13 nachm. schrieb "Nikolaos Ftylitakis" < [email protected]>:

Hello @Fujnky https://github.com/fujnky

after receiving the result from decodeImage that is a QString, can't you just use QString::toLocal8Bit() http://doc.qt.io/qt-5/qstring.html#toLocal8Bit ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ftylitak/qzxing/issues/75#issuecomment-370567671, or mute the thread https://github.com/notifications/unsubscribe-auth/AAR6qIquLU8sorl0-i1BpyfJ5Jr4mUD2ks5tbapqgaJpZM4Sbb5K .

larsfu avatar Mar 06 '18 12:03 larsfu

I have created a new branch over the name "emitTagRawBytes" to test this functionality.

Now, when a tag is detected, it also emits the following signal:

void tagFound(QByteArray tagRawBytes);

Could you please check if this works for you?

ftylitak avatar Mar 06 '18 13:03 ftylitak

Thanks for your efforts! It does emit some binary data, but it's rather strange. This data matrix contains "hello", which translates to 68656c6c6f in hexadecimal. That’s also what I get by calling decoder.decodeImage(img).toLatin1().toHex(); (which works fine this time, because there’s no null byte). But when I try it this way:

QObject::connect(&decoder, 
                 QOverload<QByteArray>::of(&QZXing::tagFound),
                 this,
                 [](QByteArray barcode){
                     qDebug() << barcode.toHex();
                 }
);

I get 69666d6d7081a138ce65fb932ac057ed851cb249df76. No idea where the error lies..

larsfu avatar Mar 07 '18 22:03 larsfu