惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - Red_angelX

越狱iphone命令行ssh无法连接问题解决 Fedora22编译Qt3.3.X 黑科技项目:英雄无敌III Mod <<Fallen Angel>>介绍 中兴MF667S WCDMA猫Linux拨号笔记 NES模拟器开发-PPU笔记 Source Insight 3.X utf8支持插件更新 NES模拟器开发-CPU笔记 记录Qt的一个诡异Bug 准备开发一款开源NES模拟器 Source Insight 3.X 插件新loader发布 Source Insight 3.X utf8支持插件震撼发布 c语言非线程安全函数引发的BUG一列 Source Insight 3.X 标签插件v1.0发布 MinGW编译dll以及静态链接pthread BMP图片魔法师KeyGen C#将Trace,Debug信息输出到控件上 让LuaInterface 2.0.1支持中文 五线谱编辑Demo(MFC) C#贴边自动隐藏组件完美版
用Codeblocks的MinGW编译CxImage
Red_angelX · 2012-08-30 · via 博客园 - Red_angelX

1,先到官网下载CxImage,地址:http://www.xdp.it/download.htm 我这里下载的是cximage600_full.

2,解压,发现里面只有个vc6的工程,没关系,打开Codeblocks,转换工程,成功以后,删除不要的工程CxImageCrtDll和CxImagemfcdll还有demo和demoDll,因为我们是用MinGw编译,这两工程是提供vc6和mfc的dll.

3,开始编译, 先编译图像库和支持库jasper,jbig,jpeg,libdcr,mng,Tiff,zlib得到对应的lib***.a,新建一个libs文件,把.a拷贝进去

编译之前先配置cximage,打开 ximacfg.h

/////////////////////////////////////////////////////////////////////////////

// CxImage supported features

#define CXIMAGE_SUPPORT_ALPHA          1

#define CXIMAGE_SUPPORT_SELECTION      1

#define CXIMAGE_SUPPORT_TRANSFORMATION 1

#define CXIMAGE_SUPPORT_DSP            1

#define CXIMAGE_SUPPORT_LAYERS   1

#define CXIMAGE_SUPPORT_INTERPOLATION  1

#define CXIMAGE_SUPPORT_DECODE 1

#define CXIMAGE_SUPPORT_ENCODE 1 //<vho><T.Peck>

#define CXIMAGE_SUPPORT_WINDOWS 0

/////////////////////////////////////////////////////////////////////////////

// CxImage supported formats

#define CXIMAGE_SUPPORT_BMP 1

#define CXIMAGE_SUPPORT_GIF 1

#define CXIMAGE_SUPPORT_JPG 1

#define CXIMAGE_SUPPORT_PNG 1

#define CXIMAGE_SUPPORT_ICO 0

#define CXIMAGE_SUPPORT_TIF 1

#define CXIMAGE_SUPPORT_TGA 0

#define CXIMAGE_SUPPORT_PCX 0

#define CXIMAGE_SUPPORT_WBMP 0

#define CXIMAGE_SUPPORT_WMF 0

#define CXIMAGE_SUPPORT_JP2 0

#define CXIMAGE_SUPPORT_JPC 0

#define CXIMAGE_SUPPORT_PGX 0

#define CXIMAGE_SUPPORT_PNM 0

#define CXIMAGE_SUPPORT_RAS 0

#define CXIMAGE_SUPPORT_JBG 0 // GPL'd see ../jbig/copying.txt & ../jbig/patents.htm

#define CXIMAGE_SUPPORT_MNG 0

#define CXIMAGE_SUPPORT_SKA 0

#define CXIMAGE_SUPPORT_RAW 0 

把自己不需要的功能修改为0,需要的为1. 

然后开始编译cximage,编译前注意Debug版本就都要用Debug的库,Realese版本就都用Realese库,首先报错

 D:\cximage600_full_cp\CxImage\ximadsp.cpp|3507|error: 'max' was not declared in this scope|

D:\cximage600_full_cp\CxImage\ximadsp.cpp|3507|error: 'min' was not declared in this scope| 

查看了max,min其实有定义的,但是找不到奇怪,在ximadsp.cpp上加上using namespace std; 用std里面的先代替吧,

继续编译,又提示

D:\cximage600_full_cp\CxImage\ximaexif.cpp|752|error: 'isprint' was not declared in this scope| 

没找到isprint,在linux下man一下,发现在ctype里,加上#include <ctype.h> ,继续,仍然报错

D:\cximage600_full_cp\CxImage\ximawnd.cpp|1222|error: '_tcsclen' was not declared in this scope| 

把_tcsclen替换为_tcslen函数,再编译,终于成功了

ar.exe: creating D:\cximage600_full_cp\CxImage\Debug\libcximage.a 

为了测试是否真的成功了,自己写个测试程序测试

 1 #include <iostream>
 2 #include "../ximage.h"
 3 
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     CxImage img;
 9     img.Load("./old.jpg",CXIMAGE_FORMAT_JPG);
10     if(img.IsValid())
11     {
12         img.Save("./new.png",CXIMAGE_FORMAT_PNG);
13     }
14 
15     return 0;

16 }

设置好工程的链接目录和链接库,先在Search directories的Linker里设置libs的路径,我这里为http://www.cnblogs.com/libs,然后在Linker Settings的Other linker options:中加入

-lcximage
-lTiff
-lpng
-lJpeg

-lzlib

编译报错

..\..\libs\libcximage.a(ximasel.o):ximasel.cpp|| undefined reference to `CreateRectRgn@16'|

..\..\libs\libcximage.a(ximasel.o):ximasel.cpp|| undefined reference to `CombineRgn@16'|

..\..\libs\libcximage.a(ximasel.o):ximasel.cpp|| undefined reference to `DeleteObject@4'|

..\..\libs\libcximage.a(ximasel.o):ximasel.cpp|| undefined reference to `CreateRectRgn@16'|

..\..\libs\libcximage.a(ximasel.o):ximasel.cpp|| undefined reference to `CombineRgn@16'|

..\..\libs\libcximage.a(ximasel.o):ximasel.cpp|| undefined reference to `DeleteObject@4'|

||=== Build finished: 6 errors, 0 warnings ===|

 g了一下是gdi32里的函数,在链接库里面再加上-lgdi32,再编译成功,经测试,测试程序已经可以实行图像格式转换了

最后是打包发布,让其他程序可以调用他 

把libs目录拷出来,还有以下头文件

 xfile.h ximacfg.h ximadef.h ximage.h xiofile.h xmemfile.h

调用的时候只要include ximage.h就可以了

提供一个我编译好的库cximage_mingw

最后吐槽一下,个人觉得cximage并不是很好用,代码的移植性并不算太好,不像是个跨平台项目. 继续寻找其他的开源图像库