web*_*dev 3 c++ eclipse-cdt cimg
我是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;
}
Run Code Online (Sandbox Code Playgroud)
但是我不能运行我的程序,因为它说:
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.
Run Code Online (Sandbox Code Playgroud)
虽然我可以看到图像,但无法保存。搜寻了一下之后,我发现有人说要安装ImageMagick,但我已经安装了它,但没有帮助。论坛中的某些人说可以针对libjpeg,libpng,libmagick ++进行编译。但是我不知道如何针对那些库进行编译。我正在使用Eclipse CDT插件编写C ++项目。请帮我 。
我遇到了同样的错误,安装GraphicsMagick(不是ImageMagick)对我有帮助。
我已经从ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/windows/下载并安装了GraphicsMagick-1.3.26-Q8-win64-dll.exe 。如果需要,您可以选择另一个:
请注意,提供行业标准24/32位像素的QuantumDepth = 8版本(Q8)与提供48/64位像素用于高分辨率彩色的QuantumDepth = 16版本(Q16)相比,消耗的内存减少一半,CPU减少约30%。 。Q8版本适合处理打算在计算机屏幕上查看的典型照片。如果要处理胶片,科学或医学图像,使用ICC色彩配置文件或处理对比度有限的图像,则建议使用Q16版本。
重要说明:在安装过程中,请勿删除“更新可执行文件的搜索路径”复选框,该复选框将更新环境变量%PATH%,使该变量gm.exe可从任何位置使用。
就我而言,还需要安装Ghostscript-GraphicsMagick强烈建议安装。有一个指向x64 Ghostscript的链接:https : //sourceforge.net/projects/ghostscript/files/GPL%20Ghostscript/9.09/gs909w64.exe/download(我已将其放在此处,因为来自GraphicMagick网站的链接使您可以仅32位)。
在那之后,它对我来说很好。