Smart Car image player

Source: Internet
Author: User

Smart Car image player

Author: 1.1 drops of beer http://beer.cnblogs.com/

 

Image PLAYER:

 

 

A smart car uses an on-board camera to collect runway data and then stores the data in the memory of the Central Control Board of the car. After the vehicle runs for a week, serial communication is sent to the computer and saved as a binary file.

The software then reads the binary file, reads 40*80 = 3200 data at a time, then draws 3200 gray pixels with GDI, and uses the timer, reading data from the file and re-drawing the file at intervals, this animation is similar to the player function.

This is a software written in vc6.0 when I was a junior. Now I want to, but it is not very practical. I can only collect on-site data and perform some host computer simulation. However, it's just a little effort of my junior year. Now clean up the hard disk, and make a video of the effect demonstration of the software, as a souvenir, and then delete it.

 

The main technical problems are reading files, GDI plotting, and timer.

1. Read files

 Void Cpicmoviedlg: onopenfile (){ // Todo: add your control notification handler code here  // Open the file  // Create a file name cache (filebuffer) and a file read cache (rbuffer)  // If the cache is not set here, an error will occur in the subsequent settings. If the request is dynamic, use memset or for loop to clear the Array  Char Filebuffer [5010] = {0}, rbuffer [row * column] = {0 }; // Define a cfile class to process files // Cfile in; // put it in the member variables in this dialog box. Because I want to continue to operate this file. There must be a long generation cycle .??? Balance Measure  // Define a cfiledialog class to display the standard open file dialog box Cfiledialog indlg (false, null, _ T (" Custom file type (*. Sav) | *. Sav | all files (*. *) | *. * | "), Null); indlg. m_ofn.lpstrtitle = _ T (" Open a custom file "); // Set a file name cache, because the built-in file name cache length of cfiledialog is only, but in many cases, the file path is much larger than this number. To be safe, you must set a file name cache. Indlg. m_ofn.lpstrfile = filebuffer; // Set the cache Length Indlg. m_ofn.nmaxfile = 5000; // Display the dialog box and process the events with the OK button  If (Indlg. domodal () = idok ){ // Open the file in read-only mode If (In. Open (indlg. getpathname (), cfile: moderead) {operatefile (); bstopflag = 1; // The file is not automatically played after it is opened.  // Close the file  // In. Close (); // place the statement inProgramEnd Time.  // MessageBox ("file opened successfully", "done", mb_iconexclamation | mb_ OK ); } Else {MessageBox (" Opening the file failed. You may not close the current file. "," Failed ", Mb_iconstop | mb_ OK); bopenflag = 0 ;}}}

 

 

 

2. pixels drawn by GDI

 

VoidCpicmoviedlg: draworigin (byte datatemp [] [column], CDC * PDC ){For(IntI = 0; I <row; I ++)For(IntJ = 0; j <column; j ++ ){IntRecwidth = 8;IntRecheight = 14; colorref clrrec = RGB (datatemp [I] [J], datatemp [I] [J], datatemp [I] [J]); PDC-> rectangle (recwidth * j/2, recheight * I/2, recwidth * (J + 1)/2, recheight * (I + 1)/2 );// The following Fill function overwrites all the original paint effects.PDC-> fillsolidrect (recwidth * j/2, recheight * I/2, recwidth/2, recheight/2, clrrec );}}

 

 

 

 

3. Timer

 

When the dialog box is initialized, set the timer and then execute the drawing function in the timer event. For more information about the usage, visit the internet.

 

 

End: This article is not a technical Article, but a commemorative article of your own. Therefore, the details of the solution are not described in detail. After writing this articleSource codeAll deleted. Only the above ideas are left behind.

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.