[Qt-interest] Convert an array to a JPEG

Andreas Pakulat apaku at gmx.de
Fri Sep 2 13:32:33 CEST 2011


On 02.09.11 12:19:08, Robert Wood wrote:
> I will say first off I am not asking for JPEG expertise, so bear with me!
> 
> I have written a program to connect to my Oscilloscope. I can control it 
> remotely and get information back from the scope. I have successfully 
> managed to get various bits o data such as rise times, frequency of 
> signal. So, I know my basic code works.
> 
> I have downloaded a JPEG and have it sitting in a biggish array of 
> ViChar which I believe is just a normal eight bit char. I have then 
> opened a file and used QTextStream to send these bytes out, one at a 
> time into a .jpeg file.

Thats your error, don't use qtextstream if you want to read or write
binary data. A jpeg-file is not text. Simply read/write the bytes using
the QFile/QIODevice API. You can even write the complete data at once
using write( JPEGbuffer, retCnt );

Andreas




More information about the Qt-interest-old mailing list