繁体   English   中英

Magick++ 不读取图像

[英]Magick++ does not read Image

在我的第一个 magick++ 项目中,我试图读取图像、旋转并保存它。

这是来源:

#include <iostream>
#include <Magick++.h>
#include <stdio.h>

using namespace std; 
using namespace Magick; 

int main(int argc, char *argv[]) {
    if (argc < 3)
   {
       printf("Usage: %s <Input file> <Output file>", argv[0]);
        return 1;
   }

   try{
        printf("Opening... %s\n", argv[1]);
        Magick::Image image(argv[1]);

        printf("Rotating...\n");
        image.rotate(45);

        printf("Opening... %s\n", argv[2]);
        image.write(argv[2]);
   }

   catch( Exception &error_ ) 
    { 
      cout << "Caught exception: " << error_.what() << endl; 
      return 1; 
    } 
  return 0;
}

我用 cmake (->msvc) 编译程序。 它基本上编译得很好,它只是抛出了很多这种形式的 C4251 警告:

"Magick::PathMovetoRel::_coordinates": class "std::vector<Magick::Coordinate,std::allocator<Magick::Coordinate>>" erfordert eine DLL-Schnittstelle, die von Clients von class "Magick::PathMovetoRel" verwendet wird [C:\Users\jfi\Desktop\Hints_Scripts\InsortAP_Toolbox\VSCode\IMhelloworld_cmake\build\IMHelloWorld.vcxproj]

还有一个 C4275 警告:

{
"resource": "/C:/Program Files/ImageMagick-7.0.9-Q8/include/Magick++/Exception.h",
"owner": "cmake-build-diags",
"code": "C4275",
"severity": 4,
"message": "class \"std::exception\" ist keine DLL-Schnittstelle und wurde als Basisklasse für die DLL-Schnittstelle class \"Magick::Exception\" verwendet [C:\\Users\\jfi\\Desktop\\Hints_Scripts\\InsortAP_Toolbox\\VSCode\\IMhelloworld_cmake\\build\\IMHelloWorld.vcxproj]",
"source": "MSVC",
"startLineNumber": 23,
"startColumn": 3,
"endLineNumber": 23,
"endColumn": 3
}

程序在读取图像时停止。 它不会给出任何错误消息。 我可以向magick ++添加一些详细信息吗?

谢谢你的帮助!

从文档

确保在使用 Magick++ 库之前初始化 ImageMagick 库。 这种初始化是通过将 ImageMagick DLL 的路径(假设与您的程序在同一目录中)传递给 InitializeMagick() 函数调用来执行的。 这通常通过提供程序路径 (argv[0]) 来执行,如下例所示:

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

你不是在调用InitializeMagick

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM