CxImage的編譯及簡單使用舉例


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
 
  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
 
  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
 
  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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM