The serial camera got the JPEG data of an image, I copied the data to TXT document, I want to change the data into an image

Source: Internet
Author: User


From the serial camera to get an image of the JPEG data, I copied the data to TXT document, want to change the data into an image, in VC + + should do? Read some information, some people said to save directly to JPG format, so I changed the filename suffix. txt to. jpg, but "no preview" is displayed when it is opened. I have implemented the following programs in VC + +:


FILE *pfile=fopen ("Tst.txt","RB");//tst.txt for JPEG data         Char*Pbuf;fseek (PFile,0, seek_end);intlen=Ftell (pFile);p buf=New Char[len+1];rewind (pFile); Fread (PBuf,1, Len,pfile);p Buf[len]=0; fclose (pFile); FILE*pfilep=fopen ("tst1.jpg","WB");//write in binary mode, tst1.jpg to the picture file to be savedfwrite (PBuf,1, Len,pfilep); fclose (PFILEP); MessageBox ("Finish writing!");


But the result is "no preview". Do not know how to do good, please elder brother eldest sister master help pointing, Brother grateful Ah!

has been resolved, because the format is not written correctly, thank you very much for your help!

The serial camera got the JPEG data of an image, I copied the data to TXT document, I want to change the data into an image

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.