藏族舞蹈男生分解动作:使用zlib对swf压缩文件进行解压缩--学习纪事

来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 02:28:19
学习纪事
Zlib库的版本及下载地址- -|回首页 |2006年索引 | - -swf文件格式
使用zlib对swf压缩文件进行解压缩- -
在flash6.0以后的版本中,输出文件时,都提供了压缩这一选项,如果要在程序中获得flash的内容,必须对flash进行解压缩。它使用的压缩方法是zlib开放源码的压缩方法。从第9个字节开始到文件末尾全部进行了压缩,对其解压缩也是非常简单,可以使用zlib1.dll中提供的uncompress对其进行解压缩。
具体使用方法,参见zlib的官方网站:http://www.zlib.net
里面惟一需要注意的是:压缩和解压缩的缓冲区的大小,应该是实际内容大小的 1.01倍+12 个字节。否则就可能出现错误。
基本代码如下:
CFile tmpfile;
tmpfile.Open(filepath,CFile::modeRead);
DWORD complen=tmpfile.GetLength();
BYTE* header=(BYTE*)::GlobalAlloc(GPTR,8);
BYTE* buf=(BYTE*)::GlobalAlloc(GPTR,(complen-8)*1.01+12);
BYTE* bufd=(BYTE*)::GlobalAlloc(GPTR,(filelen-8)*1.01+12);
tmpfile.Read(header,8);
tmpfile.ReadHuge(buf,complen-8);
tmpfile.Close();
unsigned long destlen;//return the value of the destlen.
uncompress(bufd,&destlen,buf,(complen-8)*1.01+12);
//uncompress the swf file and return the destination file length.
header[0]='F';//change the header indentifier.
CString temp1,temp2;
temp1=filepath.Left(filepath.GetLength()-4);
temp2.Format("~%s$.swf",temp1);
CFile filedes;
filedes.Open(temp2,CFile::modeCreate|CFile::modeWrite);
filedes.Write(header,8);
filedes.Write(bufd,destlen);
filedes.Close();
::GlobalFree(buf);
::GlobalFree(bufd);
return temp2;
- 作者:ar4ever 2006年10月7日, 星期六 20:14
你可以使用这个链接引用该篇日志 http://publishblog.blogdriver.com/blog/tb.b?diaryID=1233137
发布人: 邮箱:
主 页:
评论内容:

2003-2004 BLOGDRIVER.COM All rights reserved