[Interest] displaying Qt-coded JPEG image in browser

Alexander Carôt alexander_carot at gmx.net
Fri Jan 26 16:47:55 CET 2024


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

Thanks for general comments, hints and especially this working solution ! It does the job very well and besides single images it also works for 25 fps video streams (what I did not expect).

Thanks again and
all the best

Alex

--
http://www.carot.de
Email : Alexander at Carot.de
Tel.: +49 (0)177 5719797


> Gesendet: Freitag, 26. Januar 2024 um 16:17 Uhr
> Von: "Thiago Macieira" <thiago.macieira at intel.com>
> An: "qt qt" <interest at qt-project.org>
> Cc: "Alexander Carôt" <alexander_carot at gmx.net>
> Betreff: Re: [Interest] displaying Qt-coded JPEG image in browser
>
> 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
>


More information about the Interest mailing list