了解rle压缩请帮帮忙

luxin24 2004-01-22 09:56:11
我想在vc下实现对经rle压缩的文件进行解压,不知该如何操作,尤其是对每一字节高位和低位进行读取不是很清楚,请高手详细指点
...全文
75 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangcrony 2004-01-26
  • 打赏
  • 举报
回复
樓上的地址無效啊﹗
樓主要的是這個嗎﹕
char *curl_escape(const char *string, int length)
{
int alloc = (length?length:(int)strlen(string))+1;
char *ns = (char*)malloc(alloc);
char *testing_ptr = NULL;
unsigned char in;
int newlen = alloc;
int index=0;

length = alloc-1;
while(length--) {
in = *string;
if(!(in >= 'a' && in <= 'z') &&
!(in >= 'A' && in <= 'Z') &&
!(in >= '0' && in <= '9')) {
/* encode it */
newlen += 2; /* the size grows with two, since this'll become a %XX */
if(newlen > alloc) {
alloc *= 2;
testing_ptr = (char*)realloc(ns, alloc);
if(!testing_ptr) {
free( ns );
return NULL;
}
else {
ns = testing_ptr;
}
}
sprintf(&ns[index], "%%%02X", in);

index+=3;
}
else {
/* just copy this */
ns[index++]=in;
}
string++;
}
ns[index]=0; /* terminate it */
return ns;
}

#define ishex(in) ((in >= 'a' && in <= 'f') || (in >= 'A' && in <= 'F') || (in >= '0' && in <= '9'))

char *curl_unescape(const char *string, int length)
{
int alloc = (length?length:(int)strlen(string))+1;
char *ns = (char*)malloc(alloc);
unsigned char in;
int index=0;
unsigned int hex;

if( !ns ) {
return NULL;
}

while(--alloc > 0) {
in = *string;
if(('%' == in) && ishex(string[1]) && ishex(string[2])) {
/* this is two hexadecimal digits following a '%' */
char hexstr[3];
char *ptr;
hexstr[0] = string[1];
hexstr[1] = string[2];
hexstr[2] = 0;

hex = strtol(hexstr, &ptr, 16);

in = hex;
string+=2;
alloc-=2;
}

ns[index++] = in;
string++;
}
ns[index]=0; /* terminate it */
return ns;
}

编码函数
char *curl_escape(const char *string, int length)

解码函数
char *curl_unescape(const char *string, int length)
lovenoend 2004-01-26
  • 打赏
  • 举报
回复
简单的RLE压缩程序
http://www0.ccidnet.com/tech/msrc/2001/03/09/58_1806.html

16,467

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧