Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/150.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在MFC2010中解码动画gif文件_C++_Image_Mfc - Fatal编程技术网

C++ 如何在MFC2010中解码动画gif文件

C++ 如何在MFC2010中解码动画gif文件,c++,image,mfc,C++,Image,Mfc,全部成交 我需要解码成一些位图文件的动画gif格式的图片在MFC2010。有没有可以解码gif图片的库?我不能使用GDIPlus,因为该程序必须在windows XP上运行。如果有人向我提供库、Activex、dll或任何类似的东西,我将不胜感激 非常感谢,, Shervin Zargham < P>使用IMAGE的C++ API():非常简单。 /*用于存储GIF帧的图像列表*/ 向量图像列表; /*读取动画GIF的所有帧*/ Magick::readImages(&imageList,“a

全部成交

我需要解码成一些位图文件的动画gif格式的图片在MFC2010。有没有可以解码gif图片的库?我不能使用GDIPlus,因为该程序必须在windows XP上运行。如果有人向我提供库、Activex、dll或任何类似的东西,我将不胜感激

非常感谢,,
Shervin Zargham

< P>使用IMAGE的C++ API():

非常简单。
/*用于存储GIF帧的图像列表*/
向量图像列表;
/*读取动画GIF的所有帧*/
Magick::readImages(&imageList,“animated.gif”);
/*根据预期结果,选择合并帧序列*/
Magick::coalesceImages(&imageList,imageList.begin(),imageList.end());
/*将每个帧存储在单独的BMP文件中*/
for(无符号整数i=0;iSS  WIC(包含在Vista中,可供XP使用)提供了<代码> CLSIDYWIGIFIFDECTOR> ,COM组件。

< P>已经很久了,但我记得曾经使用过打开Windows的旧版本的GIF和PNG文件,尽管文档似乎暗示它只适用于BMP、ICO和WMF。

< P>使用IMAGEMAGICE的C++ API(MaGICK++)来尝试这个问题。,在VS210上测试:

#include <Magick++.h>
#include <string>
#include <iostream>
#include <list>

using namespace std;
using namespace Magick;

void kk(char * nombre, char *ext)
{
/* list of Image to store the GIF's frames */
std::list<Magick::Image> imageList; 
/* read all the frames of the animated GIF */
Magick::readImages(  &imageList, nombre );
/* compone las diferencias para obtener los cuadros reales */
Magick::coalesceImages(&imageList,imageList.begin( ),imageList.end( ));
/* store each frame in a separate BMP file */
 list <Magick::Image>::iterator it;
 int i=1;
 for ( it = imageList.begin( ); it != imageList.end( ); it++ , i++)
    {
    std::string name =  "frame" +  to_string((_Longlong)(i))  + ext ;
    it->write(name);
    }
}
int main( int /*argc*/, char ** argv)
{

  // Initialize ImageMagick install location for Windows
  InitializeMagick(*argv); 
  try {
    kk("luni0.gif", ".png"); // using  ".bmp", ".jpg", ".png", OK
    return 0;
  }
    catch( exception &error_ )
    {
      cout << "Caught exception: " << error_.what() << endl;
      return 1;
    }
  }
#包括
#包括
#包括
#包括
使用名称空间std;
使用名称空间Magick;
无效kk(字符*名称,字符*外部)
{
/*用于存储GIF帧的图像列表*/
std::列表图像列表;
/*读取动画GIF的所有帧*/
Magick::readImages(&imageList,nombre);
/*不一致成分*/
Magick::coalesceImages(&imageList,imageList.begin(),imageList.end());
/*将每个帧存储在单独的BMP文件中*/
列表::迭代器;
int i=1;
for(it=imageList.begin();it!=imageList.end();it++,i++)
{
std::string name=“frame”+to_string((_Longlong)(i))+ext;
它->写(名字);
}
}
int main(int/*argc*/,char**argv)
{
//初始化Windows的ImageMagick安装位置
初始化magick(*argv);
试一试{
kk(“luni0.gif”,“.png”);//使用“.bmp”,“.jpg”,“.png”,确定
返回0;
}
捕获(异常和错误)
{

亲爱的Zankinster,我已经下载了Magick并按照说明将其安装到我的系统上。但是,我在第一步遇到了一个问题。我在visual studio 2010下打开并转换了configure.sln。当我按下播放按钮运行程序时,我收到一个错误;声明“无法启动程序configure.exe…系统找不到特定文件。”非常感谢您提供在visual 2010下安装它的说明。非常感谢,ShervinZargham@shervin我想您是在遵循。它看起来像是
configure
未编译或不在正确的目录中,请检查您是在release not debug中编译的。@Zankister:我转到了VisualMagick\configure文件夹并打开configure.sln。我还坐在要发布的构建配置上。但是我仍然收到相同的错误。@Zankister:我如何确认配置的正确目录?我在解决方案资源管理器中右键单击了“配置”并按了“全部重新构建”。你认为我需要更新我的visual studio吗?@Zankister:谢谢你我建议你给我推荐Magick++库,虽然我没有成功使用它。实际上我花了很多时间,但没有结果:(.非常感谢您的回答。它支持动画gif吗?可以给我举个例子吗?对我来说,将所有gif帧提取到一组位图中以便对其进行处理非常重要。@shervin:接口明确支持帧数和帧数;gif是它的主要图像格式需要。我已经按照您的建议使用WIC来解码我的GIF图像。此时,我可以访问所有帧并在屏幕上绘制它们,但问题是,每个帧中每个图像的大小都不同。因此,当我希望按顺序在屏幕上显示所有帧时,动画会移动,因为每个帧的宽度和高度都不同。我会这样做非常感谢您在这方面的帮助。非常感谢您的回答。它支持动画gif吗?能给我举个例子吗?对我来说,将所有gif帧提取到一组位图中以便对其进行处理非常重要。@shervin:就像我说的,那是很久以前的事了,所以我不记得细节和细节我没有访问代码的权限。可能情况已经发生了变化,因为文档中没有提到GIF。您必须进行实验。
#include <Magick++.h>
#include <string>
#include <iostream>
#include <list>

using namespace std;
using namespace Magick;

void kk(char * nombre, char *ext)
{
/* list of Image to store the GIF's frames */
std::list<Magick::Image> imageList; 
/* read all the frames of the animated GIF */
Magick::readImages(  &imageList, nombre );
/* compone las diferencias para obtener los cuadros reales */
Magick::coalesceImages(&imageList,imageList.begin( ),imageList.end( ));
/* store each frame in a separate BMP file */
 list <Magick::Image>::iterator it;
 int i=1;
 for ( it = imageList.begin( ); it != imageList.end( ); it++ , i++)
    {
    std::string name =  "frame" +  to_string((_Longlong)(i))  + ext ;
    it->write(name);
    }
}
int main( int /*argc*/, char ** argv)
{

  // Initialize ImageMagick install location for Windows
  InitializeMagick(*argv); 
  try {
    kk("luni0.gif", ".png"); // using  ".bmp", ".jpg", ".png", OK
    return 0;
  }
    catch( exception &error_ )
    {
      cout << "Caught exception: " << error_.what() << endl;
      return 1;
    }
  }