1. 程式人生 > >CxImage的編譯及簡單使用舉例

CxImage的編譯及簡單使用舉例

end ron bin 源碼 clu cximage itl tools ostream

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. #include "targetver.h"
  3. #include <stdio.h>
  4. #include "../../cximage702_full/CxImage/ximage.h"


stdafx.cpp:

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


testCxImage.cpp:

[cpp] view plain copy
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5. int main(int argc, char* argv[])
  6. {
  7. CxImage image;
  8. string imageName = "1.jpg";
  9. string imageSave = "2.tif";
  10. image.Load(imageName.c_str(), CXIMAGE_FORMAT_JPG);
  11. cout<<image.GetBpp()<<endl;
  12. if (image.IsValid()) {
  13. image.GrayScale();
  14. image.Save(imageSave.c_str(), CXIMAGE_FORMAT_TIF);
  15. cout<<"success"<<endl;
  16. }
  17. cout<<"ok"<<endl;
  18. return 0;
  19. }


GitHub:https://github.com/fengbingchun/CxImage_Test

CxImage的編譯及簡單使用舉例