在我的第一个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++中添加一些冗长吗?
谢谢你的帮忙!
发布于 2020-03-28 04:09:47
从文档中
确保在使用ImageMagick库之前初始化Magick++库。这种初始化是通过向InitializeMagick()函数调用传递ImageMagick DLL(假定与您的程序位于同一目录)的路径来执行的。这通常是通过提供程序的路径(argv)来执行的,如下例所示:
int main(int argc,char** argv) { InitializeMagick(*argv);
您不会调用InitializeMagick
https://stackoverflow.com/questions/60893168
复制相似问题