CxImage的简单用法
来源:互联网 发布:linux shell启动 编辑:程序博客网 时间:2024/05/22 03:33
#include <iostream>#include <cstdlib>#include <fstream>using namespace std;#include "ximage.h"#pragma comment(lib, "png.lib")#pragma comment(lib, "jpeg.lib")#pragma comment(lib, "zlib.lib")#pragma comment(lib, "tiff.lib")#pragma comment(lib, "jbig.lib")#pragma comment(lib, "mng.lib")#pragma comment(lib, "jasper.lib")#pragma comment(lib, "libdcr.lib")#pragma comment(lib, "libpsd.lib")#pragma comment(lib, "cximage.lib")void LoadFromMemory();void LoadAndSaveFromFile();void ReadKey();int main(){ LoadFromMemory(); ReadKey(); return 0;}//这个函数是从内存文件中加载jpg并保存png文件void LoadFromMemory(){ std::ifstream from("0015.jpg", ios::binary); if (!from) { cout << "Can't open file 0015.jpg" << endl; return; } int iFileLen = 0; streampos pos = from.tellg(); from.seekg(0, ios::end); iFileLen = from.tellg(); //cout << "File len : " << from.tellg() << endl; from.seekg(pos); BYTE *imageMemory = new BYTE[iFileLen]; from.read((char*)imageMemory, iFileLen); CxImage image;//((TCHAR *)imageMemory, CXIMAGE_FORMAT_JPG); if (image.Decode(imageMemory, iFileLen, CXIMAGE_FORMAT_JPG)) { cout << "Decode successfuly !" << endl; } image.Save("LoadInMemory.png",::CXIMAGE_FORMAT_PNG); from.close(); delete []imageMemory;}//这个函数是从磁盘文件中加载jpg并保存png文件void LoadAndSaveFromFile(){ ::CxImage *pImage = new CxImage; pImage->Load("0015.jpg",::CXIMAGE_FORMAT_JPG); pImage->Save("0015.png",::CXIMAGE_FORMAT_PNG);}void ReadKey(){ int a = 0; cin >> a;}
下面代码演示CxImage从文件中加载图片和从内存中加载图片(很久没有写C++代码,有点生疏 )
- CxImage的简单用法
- CxImage的简单用法
- CxImage的简单用法
- CxImage的简单用法
- CxImage的简单用法
- 【转】CxImage的简单用法
- CxImage类的简单用法
- CxImage简单用法2
- Cximage的用法
- CxImage 用法 (转 的 )
- CxImage类的简单说明
- CxImage的使用及基本用法
- CxImage的使用及基本用法
- CxImage的使用以及基本用法
- CxImage的使用以及基本用法
- CxImage的使用以及基本用法
- CxImage的编译及简单使用举例
- CxImage类---函数的简单说明
- 串口号大于10的情况 - QT在windows下的串口编程
- Shell 命令
- Application package 'AndroidManifest.xml' must have a minimum of 2 segments.
- IP子网划分 推荐阅读
- sql server常用函数
- CxImage的简单用法
- 公开rtsp流媒体测试地址
- TP_Link R488多WAN口路由器花生壳功能配置,我都设置好了 但还是进不了 ping域名返回的IP是公网ip没错
- Hadoop不用eclipse去编译运行WordCount
- Vi编辑器的基本使用方法
- Spring集成Quartz定时任务框架介绍和Cron表达式详解
- 使用libpcap抓包编译错误
- 系统分析师备考
- Struts2 工作原理