CxImage的编译及简单使用举例
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 plaincopy
#pragma once
#include "targetver.h"
#include <stdio.h>
#include "../../cximage702_full/CxImage/ximage.h"
stdafx.cpp:
[cpp] view plaincopy
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
#ifdef _DEBUG
#pragma comment(lib, "../../cximage702_full/Debug/cximage.lib")
#pragma comment(lib, "../../cximage702_full/Debug/jasper.lib")
#pragma comment(lib, "../../cximage702_full/Debug/jbig.lib")
#pragma comment(lib, "../../cximage702_full/Debug/jpeg.lib")
#pragma comment(lib, "../../cximage702_full/Debug/libdcr.lib")
#pragma comment(lib, "../../cximage702_full/Debug/libpsd.lib")
#pragma comment(lib, "../../cximage702_full/Debug/mng.lib")
#pragma comment(lib, "../../cximage702_full/Debug/png.lib")
#pragma comment(lib, "../../cximage702_full/Debug/tiff.lib")
#pragma comment(lib, "../../cximage702_full/Debug/zlib.lib")
#else
#pragma comment(lib, "../../cximage702_full/Release/cximage.lib")
#pragma comment(lib, "../../cximage702_full/Release/jasper.lib")
#pragma comment(lib, "../../cximage702_full/Release/jbig.lib")
#pragma comment(lib, "../../cximage702_full/Release/jpeg.lib")
#pragma comment(lib, "../../cximage702_full/Release/libdcr.lib")
#pragma comment(lib, "../../cximage702_full/Release/libpsd.lib")
#pragma comment(lib, "../../cximage702_full/Release/mng.lib")
#pragma comment(lib, "../../cximage702_full/Release/png.lib")
#pragma comment(lib, "../../cximage702_full/Release/tiff.lib")
#pragma comment(lib, "../../cximage702_full/Release/zlib.lib")
#endif
testCxImage.cpp:
[cpp] view plaincopy
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
CxImage image;
string imageName = "1.jpg";
string imageSave = "2.tif";
image.Load(imageName.c_str(), CXIMAGE_FORMAT_JPG);
cout<<image.GetBpp()<<endl;
if (image.IsValid()) {
image.GrayScale();
image.Save(imageSave.c_str(), CXIMAGE_FORMAT_TIF);
cout<<"success"<<endl;
}
cout<<"ok"<<endl;
return 0;
1、 从http://sourceforge.net/projects/cximage/下载最新的CxImage 702源码;【邮件中已备份】
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 plaincopy
#pragma once
#include "targetver.h"
#include <stdio.h>
#include "../../cximage702_full/CxImage/ximage.h"
stdafx.cpp:
[cpp] view plaincopy
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
#ifdef _DEBUG
#pragma comment(lib, "../../cximage702_full/Debug/cximage.lib")
#pragma comment(lib, "../../cximage702_full/Debug/jasper.lib")
#pragma comment(lib, "../../cximage702_full/Debug/jbig.lib")
#pragma comment(lib, "../../cximage702_full/Debug/jpeg.lib")
#pragma comment(lib, "../../cximage702_full/Debug/libdcr.lib")
#pragma comment(lib, "../../cximage702_full/Debug/libpsd.lib")
#pragma comment(lib, "../../cximage702_full/Debug/mng.lib")
#pragma comment(lib, "../../cximage702_full/Debug/png.lib")
#pragma comment(lib, "../../cximage702_full/Debug/tiff.lib")
#pragma comment(lib, "../../cximage702_full/Debug/zlib.lib")
#else
#pragma comment(lib, "../../cximage702_full/Release/cximage.lib")
#pragma comment(lib, "../../cximage702_full/Release/jasper.lib")
#pragma comment(lib, "../../cximage702_full/Release/jbig.lib")
#pragma comment(lib, "../../cximage702_full/Release/jpeg.lib")
#pragma comment(lib, "../../cximage702_full/Release/libdcr.lib")
#pragma comment(lib, "../../cximage702_full/Release/libpsd.lib")
#pragma comment(lib, "../../cximage702_full/Release/mng.lib")
#pragma comment(lib, "../../cximage702_full/Release/png.lib")
#pragma comment(lib, "../../cximage702_full/Release/tiff.lib")
#pragma comment(lib, "../../cximage702_full/Release/zlib.lib")
#endif
testCxImage.cpp:
[cpp] view plaincopy
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
CxImage image;
string imageName = "1.jpg";
string imageSave = "2.tif";
image.Load(imageName.c_str(), CXIMAGE_FORMAT_JPG);
cout<<image.GetBpp()<<endl;
if (image.IsValid()) {
image.GrayScale();
image.Save(imageSave.c_str(), CXIMAGE_FORMAT_TIF);
cout<<"success"<<endl;
}
cout<<"ok"<<endl;
return 0;
}
//显示
CxImage image;
if(image.load("name",类型))
{
CDC *pDC = GetDC();
image.Draw(pDC->GetSafeHDC(),CRect rect(0,0,100,100));
pDC->DeleteDC;
}
参考网址:http://blog.csdn.net/fengbingchun/article/details/38795713