IrrLicht引擎研究
鬼火引擎研究
博客园
首页
社区
新文章
新随笔
订阅
管理
posts - 22, comments - 40, trackbacks - 0
2008年1月13日
从内存中加载图片资源
1 使用工具将文件转为字节数组,这里用[bin2h.exe]
比如准备个文件 testpng.png
使用命令
bin2h testpng.png
将生成 testpng.h,内容如下
unsigned int
testpng_size=<size>;
unsigned char
testpng[]={...};
2 将文件加入到工程中
使用如下代码获取ITextrue接口,env为
IGUIEnvironment
//包含文件
#include "testpng.h"
....
//获得文件系统
IFileSystem * pFS = env->getFileSystem();
//创建读文件接口,这里特别注意第3个参数,其后缀一定要和文件格式一致,如果用的是bmp,则应该是testpng.bmp
IReadFile * pMFR = pFS->createMemoryReadFile(testpng,testpng_size,"testpng.png",false);
//获取Texture
ITexture * pTxtPng = driver->getTexture(pMFR);
3 使用pTxtPng
posted @ 2008-01-13 15:26 安徽飞雪游戏工作室 阅读(581) 评论(0)
编辑