ImageMagick--VS2015环境配置、开发(registrykeylookupFailed)
Title:
ImageMagick–VS2015环境配置、开发
生命不止,blog继续。
《ImageMagick–介绍》对ImageMagick进行了简单的介绍,如今就看看如何在vs工程中使用。
新建一个控制台工程(略)
然后配置工程:
1包含目录
2导入lib
3选择MT
测试代码:
#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;
int main(int argc, char **argv)
{
InitializeMagick(*argv);
// Construct the image object. Seperating image construction from the
// the read operation ensures that a failure to read the image file
// doesn't render the image object useless.
Image image;
try {
// Read a file into image object
/* image.read("C:\\Users\\xueba\\Documents\\XueBa\\wangshubo\\00.JPG");*/
image.read("00.JPG");
cout << "image.columns()" << image.columns() << endl;
cout << "image.size().width()" << image.size().width() << endl;
cout << "image.size().height()" << image.size().height() << endl;
image.resize(Geometry(1600, 900, 0, 0));
cout << "resize image.columns()" << image.columns() << endl;
cout << "resize image.size().width()" << image.size().width() << endl;
cout << "resize image.size().height()" << image.size().height() << endl;
// Write the image to a file
image.write("00.JPG");
}
catch (Exception &error_)
{
cout << "Caught exception: " << error_.what() << endl;
system("pause");
return 1;
}
system("pause");
return 0;
}
错误1
Caught exception: test_image_magick.exe: unable to open image 'h応': No such file or directory @ error/blob.c/OpenBlob/2695
方案:
这个原因就是我们应该选择MT,也就是选择release:
Magick++ doesn’t like to run in Visual Studio’s Debug mode so you have to build as a Release or ImageMagick won’t be happy.
错误2
我们打了一个包,包含了所有需要的dll,兴致勃勃的拿给用户。结果在用户的电脑上出现这个错误:
方案:
不用使用安装的imagemagick,而是使用源码自己编译,并改变文件查找的顺序:
http://www.imagemagick.org/discourse-server/viewtopic.php?t=26856
还没有评论,来说两句吧...