ImageMagick--VS2015环境配置、开发(registrykeylookupFailed)

约定不等于承诺〃 2022-07-15 12:18 257阅读 0赞

Title:
ImageMagick–VS2015环境配置、开发

生命不止,blog继续。

《ImageMagick–介绍》对ImageMagick进行了简单的介绍,如今就看看如何在vs工程中使用。

新建一个控制台工程(略)

然后配置工程:
1包含目录
这里写图片描述
2导入lib
这里写图片描述
3选择MT
这里写图片描述
测试代码:

  1. #include <Magick++.h>
  2. #include <iostream>
  3. using namespace std;
  4. using namespace Magick;
  5. int main(int argc, char **argv)
  6. {
  7. InitializeMagick(*argv);
  8. // Construct the image object. Seperating image construction from the
  9. // the read operation ensures that a failure to read the image file
  10. // doesn't render the image object useless.
  11. Image image;
  12. try {
  13. // Read a file into image object
  14. /* image.read("C:\\Users\\xueba\\Documents\\XueBa\\wangshubo\\00.JPG");*/
  15. image.read("00.JPG");
  16. cout << "image.columns()" << image.columns() << endl;
  17. cout << "image.size().width()" << image.size().width() << endl;
  18. cout << "image.size().height()" << image.size().height() << endl;
  19. image.resize(Geometry(1600, 900, 0, 0));
  20. cout << "resize image.columns()" << image.columns() << endl;
  21. cout << "resize image.size().width()" << image.size().width() << endl;
  22. cout << "resize image.size().height()" << image.size().height() << endl;
  23. // Write the image to a file
  24. image.write("00.JPG");
  25. }
  26. catch (Exception &error_)
  27. {
  28. cout << "Caught exception: " << error_.what() << endl;
  29. system("pause");
  30. return 1;
  31. }
  32. system("pause");
  33. return 0;
  34. }

错误1

  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

发表评论

表情:
评论列表 (有 0 条评论,257人围观)

还没有评论,来说两句吧...

相关阅读

    相关 开发环境配置

    Gradle maven 的扩展 安装使用 1.下载解压; 2.环境变量配置(系统变量-环境变量),cmd命令 geadle -v 查看是否安装成功; GRADL