我是 C++ 编程新手,今天我试图使用 CImg 保存图像。CImg 是 C++ 模板图像处理库。
我写的基本代码是(请原谅任何语法错误,作为我代码的复制部分):
#include "CImg.h"// Include CImg library header.
#include <iostream>
using namespace cimg_library;
using namespace std;
const int screen_size = 800;
//-------------------------------------------------------------------------------
// Main procedure
//-------------------------------------------------------------------------------
int main()
{
CImg<unsigned char> img(screen_size,screen_size,1,3,20);
CImgDisplay disp(img, "CImg Tutorial");
//Some drawing using img.draw_circle( 10, 10, 60, RED);
img.save("result.jpg"); // save the image
return 0;
}
但是我无法运行我的程序,因为它说:
Invalid Parameter - 100%
'gm.exe' is not recognized as an internal or external command,
operable program or batch file.
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
[CImg] *** CImgIOException *** [instance(800,800,1,3,02150020,non-shared)] CImg<unsigned char>::save_other() : Failed to save file 'result.jpg'. Format is not natively supported, and no external commands succeeded.
terminate called after throwing an instance of 'cimg_library::CImgIOException'
what(): [instance(800,800,1,3,02150020,non-shared)] CImg<unsigned char>::save_other() : Failed to save file 'result.jpg'. Format is not natively supported, and no external commands succeeded.
虽然我可以看到图像,但我无法保存它。谷歌搜索了一下后,我发现有人说要安装 ImageMagick,我已经安装了它但没有帮助。一些论坛说要针对 libjpeg、libpng、libmagick++ 进行编译。但我不知道如何针对这些库进行编译。我正在使用 Eclipse CDT 插件编写 C++ 项目。请帮我 。