Recently, many kinds of GIF expressions on QQ. Every one of them is a classic. So I wanted to convert it into a static picture ... Never learned PS. So I wrote a few lines of code. Completed. The core code is as follows
Mainly with the help of the Qmovie class. File read Mode Select Qmovie::cacheall This allows you to cache all pictures. Then end the jumptoframe to toggle the picture. The loop is done.
[CPP]View Plaincopy
- void Mainwindow::getstaticphoto ()
- {
- if (M_gifpath = = "" | | M_savedirpath = = "")
- return;
- M_pmovie = new Qmovie;
- M_pmovie->setfilename (M_gifpath);
- M_pmovie->setcachemode (Qmovie::cacheall);
- For (int i =0; i< m_pmovie->framecount (); ++i) {
- M_pmovie->jumptoframe (i);
- Qimage image = M_pmovie->currentimage ();
- QFile file (m_savedirpath+qstring ("/%1.jpg"). Arg (i));
- File.Open (qfile::writeonly);
- Image.Save (&file, "JPG");
- File.close ();
- }
- }
[CPP]View Plaincopy
- Where M_gifpath is the path to the GIF file. <span style="font-family:arial, Helvetica, Sans-serif;" >m_savedirpath is the folder path. The converted picture resource is stored in this directory. </span>
http://blog.csdn.net/wu5151/article/details/47107189
qt Development Gadget GIF converter (use Qmovie to intercept each frame as qimage, then save as picture file with Qfile)