[Interest] displaying Qt-coded JPEG image in browser

Thiago Macieira thiago.macieira at intel.com
Fri Jan 26 16:17:39 CET 2024


On Friday, 26 January 2024 04:55:59 PST Alexander Carôt via Interest wrote:
> QString jpgBufferString( finalJpg.data() );

This here will corrupt the data, because you can't load arbitrary binary data 
into QString like this: it's trying to decode as UTF-8 and failing.

> QString encodedString = jpgBufferString.toUtf8().toBase64();

You should encode to Base64 at the QByteArray level first, before going to 
QString. So:

 QString encodedString = QString::fromLatin1(finalJpg.toBase64());

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5163 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240126/a0ea00d4/attachment.bin>


More information about the Interest mailing list