Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/132.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ ImageMagick未处理的异常_C++_Imagemagick - Fatal编程技术网

C++ ImageMagick未处理的异常

C++ ImageMagick未处理的异常,c++,imagemagick,C++,Imagemagick,我得到这个错误: 在SAMPLE APP.M.EXE中0x76ABC41F未处理的异常:微软C++异常:MaGICK::Error BROB在内存位置0x44CF1C8… 当我执行以下代码时: #include <Magick++.h> #include <iostream> using namespace std; using namespace Magick; int main(int argc,char **argv) { Initialize

我得到这个错误: 在SAMPLE APP.M.EXE中0x76ABC41F未处理的异常:微软C++异常:MaGICK::Error BROB在内存位置0x44CF1C8… 当我执行以下代码时:

#include <Magick++.h> 
#include <iostream> 
using namespace std; 
using namespace Magick; 

int main(int argc,char **argv) 
{ 
    InitializeMagick(*argv);
    Magick::Image image("100x120", "linen");
    image.fillColor("black");
    image.write("test.png");// if i comment this line there is no more error at the execution
    return 0; 
}
#包括
#包括
使用名称空间std;
使用名称空间Magick;
int main(int argc,字符**argv)
{ 
初始化magick(*argv);
Magick::图像图像(“100x120”,“亚麻”);
图像。填充颜色(“黑色”);
image.write(“test.png”);//如果我对这一行进行注释,那么执行时就不会再有错误了
返回0;
}

我建议,您捕获Magick实现引发的异常,将其写入
cout
并尝试找出发生了什么:

#include <Magick++.h> 
#include <iostream> 
using namespace std; 
using namespace Magick; 

int main(int argc,char **argv) 
{ 
    InitializeMagick(*argv);
    Magick::Image image("100x120", "linen");
    try {
        image.fillColor("black");
        image.write("test.png"); // this line causes the error
    } catch (const Exception& e) {
        cout << e.what() << endl;
    }
    return 0; 
}
#包括
#包括
使用名称空间std;
使用名称空间Magick;
int main(int argc,字符**argv)
{ 
初始化magick(*argv);
Magick::图像图像(“100x120”,“亚麻”);
试一试{
图像。填充颜色(“黑色”);
image.write(“test.png”);//此行导致错误
}捕获(常量异常和e){

cout我做了一些更改来处理异常,这段代码适合我,在VC++2013 64位上编译

这是输出

还要确保您具有写入权限,因为ErrorBlob是一个IO子系统错误

#include <Magick++.h> 
#include <iostream> 
using namespace std; 
using namespace Magick; 
int main(int argc,char **argv) 
{ 
  InitializeMagick(*argv);

  try { 
    Image image("100x120", "linen");
    image.fillColor("black");
    image.write("test.png");
  } 
  catch( Exception &error_ ) 
    { 
      cout << "Caught exception: " << error_.what() << endl; 
      return 1; 
    } 
  return 0; 
}
#包括
#包括
使用名称空间std;
使用名称空间Magick;
int main(int argc,字符**argv)
{ 
初始化magick(*argv);
试试{
图像(“100x120”,“亚麻布”);
图像。填充颜色(“黑色”);
image.write(“test.png”);
} 
捕获(异常和错误)
{ 

我能得到这个错误吗:捕获的异常:sampleapp.exe UnableToOpenBlob'#FAFAF0F0E6E6':没有这样的文件r目录@error/blob.c/OpenBlob/2643I得到这个:捕获的异常:Magick:UnableToOpenBlob'xc:#000000000000000000':没有这样的文件或目录@error/blob.c/OpenBlob/3496i得到这个错误:捕获的异常:sampleapp.exe UnableToOpenBlob'#F0F0E6E6':没有这样的文件r directory@error/blob.c/OpenBlob/2643'blob'函数用于打开流、文件和字符串,作为图像数据的可能来源。您收到的错误是因为库由于某种原因在定位其配置文件时遇到问题。可能它缺少特定应用程序所需的某些环境设置在您的计算机上安装。尝试在安装文件夹内执行以进行测试。在ImageMagick目录中?是的,如\ImageMagick-6.8.8-Q8\sampleapp.exe。如果您尝试使用安装应用程序(而不是zip)和DLL(而不是静态)重新安装库,则可能需要。尝试编译演示应用程序,如button.cpp(使用Magick++_Demo.dsw打开)并执行,如果有效,只需用代码替换button.cpp的内容并重新编译即可。这对我来说很有效。