DoubleLi

qq: 517712484 wx: ldbgliet

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  4737 随笔 :: 2 文章 :: 542 评论 :: 1615万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

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

posted on   DoubleLi  阅读(2274)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示