码迷,mamicode.com
首页 > Web开发 > 详细

c pvr转存pvr.ccz格式 (转 http://www.cnblogs.com/howeho/p/3586379.html)

时间:2017-06-20 22:14:01      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:pre   sig   c++   buffers   int   too   path   效率   复制   

pvr.ccz 是把pvr用zlib算法压缩后的图像格式,其优点是可以提升文件读取效率。 

大多数情况下我们可以用一些工具来将pvr压缩到pvr.ccz ,下面提供一个c++方法来完成这个过程

技术分享
int CompressPvrToCCZFile(unsigned char *buffer,unsigned int fileLength, const char *newFilePath)
{
  //buffer pvr文件二进制数据,fileLength 文件长度,newFilePath 保存地址 unsigned long bufferSize = fileLength; char* DestBuffer=new char[(uInt)bufferSize];memset(DestBuffer, 0, bufferSize); errno_t err; //错误变量的定义 err = compress((Bytef*)DestBuffer,(uLongf*)&bufferSize,(const Bytef*)buffer,(uLongf)fileLength); // CCZHeader header; header.version = 256; header.len = ((fileLength & 0x000000ff) >> 24 | (fileLength & 0x0000ff00) >> 8 | (fileLength & 0x00ff0000) << 8 | (fileLength & 0xff000000) << 24); header.compression_type = CCZ_COMPRESSION_ZLIB; header.sig[0] = ‘C‘; header.sig[1] = ‘C‘; header.sig[2] = ‘Z‘; header.sig[3] = ‘!‘; //保存文件 FILE *fp = fopen(newFilePath, "wb+"); if (!fp) { delete []DestBuffer; return -1; } fwrite(&header, sizeof(header), 1, fp); fwrite(DestBuffer, bufferSize, 1, fp); fclose(fp); delete []DestBuffer; return 1; }

c pvr转存pvr.ccz格式 (转 http://www.cnblogs.com/howeho/p/3586379.html)

标签:pre   sig   c++   buffers   int   too   path   效率   复制   

原文地址:http://www.cnblogs.com/czjone/p/7056245.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!