CxImage的编译及简单使用举例

来源:互联网 发布:编程求出玫瑰花数 编辑:程序博客网 时间:2024/05/17 07:10

转载自:点击打开链接

1、  从http://sourceforge.net/projects/cximage/下载最新的CxImage 702源码;

2、  解压缩后,以管理员身份打开CxImageFull_vc10.sln工程,在编译之前先将每个工程属性的Character Set由原先的Use Unicode Character Set改为Use Multi-ByteCharacter Set,首先编译jasper、jbig、jpeg、libdcr、libpsd、mng、png、tiff、zlib这9个库,然后编译cximage,cximagecrtdll,在接着编译cximagemfcdll,在编译cximagemfcdll之前,先修改其属性,linker->input->Additional Dependencies,将$(OutDir)png.lib等改为../../Debug/png.lib(../../Release/png.lib),最后编译demo、demodll;全部编译完后即可生成相应的静态库和动态库;

3、  目前CxImage支持的图像格式包括:bmp、gif、jpg、png、ico、tif、tga、pcx、wbmp、wmf、jp2、jpc、pgx、pnm、ras、jbg、mng、ska、raw和psd;

4、  CxImage中所包含的图像操作可通过打开index.htm来查看;        

5、新建一个控制台工程testCxImage,将Character Set设为Use Multi-Byte Character Set,各个文件的内容为:

stdafx.h:

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. #pragma once  
  2.   
  3. #include "targetver.h"  
  4.   
  5. #include <stdio.h>  
  6.   
  7. #include "../../cximage702_full/CxImage/ximage.h"  

stdafx.cpp:

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. #include "stdafx.h"  
  2.   
  3. // TODO: reference any additional headers you need in STDAFX.H  
  4. // and not in this file  
  5.   
  6. #ifdef _DEBUG  
  7.     #pragma comment(lib, "../../cximage702_full/Debug/cximage.lib")  
  8.     #pragma comment(lib, "../../cximage702_full/Debug/jasper.lib")  
  9.     #pragma comment(lib, "../../cximage702_full/Debug/jbig.lib")  
  10.     #pragma comment(lib, "../../cximage702_full/Debug/jpeg.lib")  
  11.     #pragma comment(lib, "../../cximage702_full/Debug/libdcr.lib")  
  12.     #pragma comment(lib, "../../cximage702_full/Debug/libpsd.lib")  
  13.     #pragma comment(lib, "../../cximage702_full/Debug/mng.lib")  
  14.     #pragma comment(lib, "../../cximage702_full/Debug/png.lib")  
  15.     #pragma comment(lib, "../../cximage702_full/Debug/tiff.lib")  
  16.     #pragma comment(lib, "../../cximage702_full/Debug/zlib.lib")  
  17. #else  
  18.     #pragma comment(lib, "../../cximage702_full/Release/cximage.lib")   
  19.     #pragma comment(lib, "../../cximage702_full/Release/jasper.lib")  
  20.     #pragma comment(lib, "../../cximage702_full/Release/jbig.lib")  
  21.     #pragma comment(lib, "../../cximage702_full/Release/jpeg.lib")  
  22.     #pragma comment(lib, "../../cximage702_full/Release/libdcr.lib")  
  23.     #pragma comment(lib, "../../cximage702_full/Release/libpsd.lib")  
  24.     #pragma comment(lib, "../../cximage702_full/Release/mng.lib")  
  25.     #pragma comment(lib, "../../cximage702_full/Release/png.lib")  
  26.     #pragma comment(lib, "../../cximage702_full/Release/tiff.lib")  
  27.     #pragma comment(lib, "../../cximage702_full/Release/zlib.lib")  
  28. #endif  

testCxImage.cpp:

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. #include "stdafx.h"  
  2. #include <iostream>  
  3. #include <string>  
  4.   
  5. using namespace std;  
  6.   
  7. int main(int argc, char* argv[])  
  8. {  
  9.     CxImage image;  
  10.     string imageName = "1.jpg";  
  11.     string imageSave = "2.tif";  
  12.   
  13.     image.Load(imageName.c_str(), CXIMAGE_FORMAT_JPG);  
  14.   
  15.     cout<<image.GetBpp()<<endl;  
  16.   
  17.     if (image.IsValid()) {  
  18.         image.GrayScale();  
  19.         image.Save(imageSave.c_str(), CXIMAGE_FORMAT_TIF);  
  20.   
  21.         cout<<"success"<<endl;  
  22.     }  
  23.   
  24.     cout<<"ok"<<endl;  
  25.     return 0;  
  26. }  

GitHubhttps://github.com/fengbingchun/CxImage_Test
0 0