0

我最近成功安装了 Magick++ 并在我的 MFC 程序中使用它(在 Visual C++ 2010 上大量尝试之后)。我的目标是将动画 gif 解码为许多位图。我需要所有的位图帧。我使用了下面的代码,但收到了很多错误。如果有人可以帮助我,我将不胜感激:)。如果有人建议我提供有关 Magick++ 的良好文档以及示例,我也将不胜感激,因为我对这个库完全陌生,这是我的代码:

#include "stdafx.h"
#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;

int main(int argc,char **argv)
{
InitializeMagick(*argv);

std::list<Magick::Image> imageList;

/* read all the frames of the animated GIF */
Magick::readImages( &imageList, "animated.gif" );

getchar();
return 0;
}

1>------ Rebuild All started: Project: test_Magiclibarary, Configuration: Debug Win32 ------
1>Build started 7/6/2013 12:52:35 AM.
1>InitializeBuildStatus:
1> Touching "Debug\test_Magiclibarary.unsuccessfulbuild".
1>ClCompile:
1> stdafx.cpp
1> test_MagiclibararyDlg.cpp
1>d:\shervin_zargham\industrial projects\led display\imagemagick-windows\imagemagick-6.8.5\magick++\lib\magick++\stl.h(2487): warning C4996: 'std::basic_string<_Elem,_Traits,_Ax>::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring(1555) : see declaration of 'std::basic_string<_Elem,_Traits,_Ax>::copy'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> d:\shervin_zargham\industrial projects\led display\programming\mfc 2010\test_magiclibarary\test_magiclibarary\test_magiclibararydlg.cpp(212) : see reference to function template instantiation 'void Magick::readImages<std::list<_Ty>>(Container *,const std::string &)' being compiled
1> with
1> [
1> _Ty=Magick::Image,
1> Container=std::list<Magick::Image>
1> ]
1> test_Magiclibarary.cpp
1> Generating Code...
1>test_MagiclibararyDlg.obj : error LNK2019: unresolved external symbol __imp__DestroyExceptionInfo referenced in function "void __cdecl Magick::readImages<class std::list<class Magick::Image,class std::allocator<class Magick::Image> > >(class std::list<class Magick::Image,class std::allocator<class Magick::Image> > *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??$readImages@V?$list@VImage@Magick@@V?$allocator@VImage@Magick@@@std@@@std@@@Magick@@YAXPAV?$list@VImage@Magick@@V?$allocator@VImage@Magick@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z)
1>test_MagiclibararyDlg.obj : error LNK2019: unresolved external symbol __imp__DestroyImageInfo referenced in function "void __cdecl Magick::readImages<class std::list<class Magick::Image,class std::allocator<class Magick::Image> > >(class std::list<class Magick::Image,class std::allocator<class Magick::Image> > *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char>> const &)" (??$readImages@V?$list@VImage@Magick@@V?$allocator@VImage@Magick@@@std@@@std@@@Magick@@YAXPAV?$list@VImage@Magick@@V?$allocator@VImage@Magick@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z)
1>test_MagiclibararyDlg.obj : error LNK2019: unresolved external symbol __imp__ReadImage referenced in function "void __cdecl Magick::readImages<class std::list<class Magick::Image,class std::allocator<class Magick::Image> > >(class std::list<class Magick::Image,class std::allocator<class Magick::Image> > *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??$readImages@V?$list@VImage@Magick@@V?$allocator@VImage@Magick@@@std@@@std@@@Magick@@YAXPAV?$list@VImage@Magick@@V?$allocator@VImage@Magick@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z)
1>test_MagiclibararyDlg.obj : error LNK2019: unresolved external symbol __imp__GetExceptionInfo referenced in function "void __cdecl Magick::readImages<class std::list<class Magick::Image,class std::allocator<class Magick::Image> > >(class std::list<class Magick::Image,class std::allocator<class Magick::Image> > *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char>> const &)" (??$readImages@V?$list@VImage@Magick@@V?$allocator@VImage@Magick@@@std@@@std@@@Magick@@YAXPAV?$list@VImage@Magick@@V?$allocator@VImage@Magick@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z)
1>test_MagiclibararyDlg.obj : error LNK2019: unresolved external symbol __imp__CloneImageInfo referenced in function "void __cdecl Magick::readImages<class std::list<class Magick::Image,class std::allocator<class Magick::Image> > >(class std::list<class Magick::Image,class std::allocator<class Magick::Image> > *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >const &)" (??$readImages@V?$list@VImage@Magick@@V?$allocator@VImage@Magick@@@std@@@std@@@Magick@@YAXPAV?$list@VImage@Magick@@V?$allocator@VImage@Magick@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z)
1>D:\Shervin_Zargham\Industrial Projects\LED Display\Programming\MFC 2010\test_Magiclibarary\Debug\test_Magiclibarary.exe : fatal error LNK1120: 5 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:10.26
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
4

1 回答 1

0

我相信您的问题与命名空间(示例定义)更相关。以下代码应该可以实现从动画 GIFS 中提取位图的目标。

#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;

int main(int argc,char **argv)
{
    InitializeMagick(*argv);

    list<Image> imageList;

    /* read all the frames of the animated GIF */
    readImages( &imageList, "animated.gif" );

    /* Iterate trough images and write to bitmap */
    writeImages(imageList.begin(),imageList.end(),"animated%02d.bmp",true);

    return 0;
}

其他 Magick++ 示例可以在类文档中找到。

于 2013-07-09T11:36:04.223 回答