CxImage類庫是一個優秀的映像操作類庫。它可以快捷地存取、顯示、轉換各種映像。用這些類庫,你要被這樣那樣的許可協議所束縛。在這點上,CxImage類庫是完全免費的。另外,在使用上述類庫時,你會遇到重重麻煩。因為它們大部分是平台無關的,且用C語言寫成,有的還夾雜著基本的C++ wrapper和成堆德編譯選項的聲明需要你去處理。而CxImage類庫在這方面做得很好。
CxImage是一個可以用於MFC 的C++類,可以開啟,儲存,顯示,轉換各種格式的影像檔,比如BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX, TGA, WMF, WBMP, JBG, J2K 等格式的檔案。可以實現BMP<->JPG,PNG <>TIFF格式等等的轉換。
......
詳細可以到作者: Davide Pizzolato ,首頁: http://www.xdp.it/
或者到http://www.codeproject.com/bitmap/CXImage.asp 下載它的源檔案和Demo例子
------------------------------------
在你的VC工程中使用這個類庫,要對工程進行如下設定(Project Settings):
|- C/C++
| |- Code Generation
| | |- Use run-time library : Multithreaded DLL (must be the same for
| | | all the linked libraries) //應該只要是多線程DLL即可,DEBUG的也行
| | |- Struct member alignment : must be the same for all the linked libraries
| |- Precompiled headers : not using precompiled headers
| |- Preprocessor
| |- Additional Include Directories: ../cximage(該處填CxImage裡的.h和.cpp檔案拷貝並匯入工程後所在的檔案夾,
填寫後在工程中include時編譯器會尋找該檔案 夾,故include的檔案無需路徑)
|- Link
|- General
|- Object/library modules: png.lib
jpeg.lib
zlib.lib
tiff.lib
jasper.lib
cximage.lib (把需要的lib檔案從CxImage中拷貝到工程中的lib檔案
所在的目錄)
並 且從CxImage中將xfile.h、ximacfg.h、ximadef.h、ximage.cpp、ximage.h、xiofile.h、 xmemfile.cpp、xmemfile.h拷貝到工
程檔案夾下並將CxImage.h檔案加入工程中即可。也可以設定vc6的"tools"中的 "include"路徑.
注意:
1.原工程裡沒有包含對 raw/libdcr.lib 的庫編譯, 要自己添架上, 否則在編譯 demo 時會缺少這個lib而出現連結錯誤
2.在所有工程裡只設定了 debug/release/unicode debug/unicode release 而且是基於 share mfc dll的, 所以在編譯時間只能選譯 Multithreaded dll, 但是如果你的工程是基於 Use MFC in static library 的話就會出現好多莫名連結錯誤
解決方案
(1)在原工程裡建立編譯設定(以 release_mt ) 為例
Build->Configurations->Add
名字為: release_mt
copy seting from: Win32 Release
OK
(2) 在Project->settings 裡將每個工程都按如下設定
|- General
|- |- Use MFC in static library
|- C/C++
| |- Code Generation
| | |- Use run-time library : Multithreaded
|- Library
| |- release_mt/xx.lib
這樣再將新產生的 *.lib拷到自己的工程後就不會出現編譯連結錯誤了! 如果要用成一個 unicode mt版方法跟上面一樣,只是在 Preprocessor definitions 裡加上: _UNICODE,UNICOD