简体   繁体   English

Magick++ 不读取图像

[英]Magick++ does not read Image

In my first magick++ Project I am trying to read an image, rotate it and save it.在我的第一个 magick++ 项目中,我试图读取图像、旋转并保存它。

This is the source:这是来源:

#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;
}

I compile the program with cmake (->msvc).我用 cmake (->msvc) 编译程序。 It basically compiles fine, it just throws a lot of C4251 warnings of this form:它基本上编译得很好,它只是抛出了很多这种形式的 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]

And one C4275 warning:还有一个 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
}

The program stops at reading the image.程序在读取图像时停止。 It does not give any errormessages.它不会给出任何错误消息。 Can I add some verbosity to magick++?我可以向magick ++添加一些详细信息吗?

Thanks for your help!谢谢你的帮助!

From the documentation从文档

Be sure to initialize the ImageMagick library prior to using the Magick++ library.确保在使用 Magick++ 库之前初始化 ImageMagick 库。 This initialization is performed by passing the path to the ImageMagick DLLs (assumed to be in the same directory as your program) to the InitializeMagick() function call.这种初始化是通过将 ImageMagick DLL 的路径(假设与您的程序在同一目录中)传递给 InitializeMagick() 函数调用来执行的。 This is commonly performed by providing the path to your program (argv[0]) as shown in the following example:这通常通过提供程序路径 (argv[0]) 来执行,如下例所示:

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

You aren't calling InitializeMagick你不是在调用InitializeMagick

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

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