简单字符压缩

zip(a){ ;自定义设置 size = 2 ;多少字节一取样 比如24为bmp 6字节 ;完毕 last = Loop { if a = { if times > 1 out = % out "
zip(a){
;自定义设置
size = 2 ;多少字节一取样 比如24为bmp 6字节

;完毕
last =
Loop
{
if a =
	{
	if times > 1
		out = % out "[" times "_" last "]"
	Else
		out = % out last
	Break
	}
StringLeft, tmp_var, a, %size%
StringTrimLeft, a, a, %size%
if tmp_var  %last%
	{
	if last =
		{
		last := tmp_var
		times = 1
		}
	Else
		{
		if times > 1
			{
			out = % out "[" times "_" last "]"
			last := tmp_var
			times = 1
			}
		Else
			{
			out = % out last
			last := tmp_var
			times = 1
			}
		}
	}
Else
	{
	times += 1
	}
}
return %out%
}

unzip(a){
StringSplit, var, a, ]
Loop % var0-1
{
tmp_var = % var%A_Index%
StringSplit, key, tmp_var, [
StringSplit, xx, key2, _
unzip_var =
Loop % xx1
{
unzip_var = % unzip_var xx2
}
out = % out key1 unzip_var
}
out := out var%var0%
Return out
}

file2hex(file){
tmp_file := FileOpen(file, "r")
while not tmp_file.AtEOF {
    tmp_file.RawRead(Data, 1)
	SetFormat, IntegerFast, hex
	tmp_hex := asc(Data)
	StringReplace, tmp_hex, tmp_hex, 0x, , All
	SetFormat, IntegerFast, d
	if StrLen(tmp_hex) = 1
	tmp_hex = 0%tmp_hex%
	hex = % hex tmp_hex
    }
tmp_file.Close()
Return hex
}

blob2file(blob,file){
if (IsObject(blob))
	{
	blob_string =
	;枚举
	tmp_file := FileOpen(file, "w")
	SetFormat, IntegerFast, hex
	For key in blob
		tmp_file.WriteUChar(key)
	SetFormat, IntegerFast, d
	}
Else ;字符
	{
	tmp_file := FileOpen(file, "w")
	StringLen, len, blob
	loop % len/2
	{
	if blob =
		break
	StringLeft, tmp_hex, blob, 2
	StringTrimLeft, blob, blob, 2
	tmp_hex := "0x" tmp_hex
	tmp_file.WriteUChar(tmp_hex)
	}
	}
tmp_file.Close()
tmp_file =
}


a := file2hex("D:Desktopno.bmp")
zip := zip(a)
FileAppend, %zip%, zip.txt
b := unzip(zip)
blob2file(b,"out.txt")
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA捐赠
共{{data.count}}人
人已捐赠
其他

简体中文

2020-3-9 4:39:44

其他

简单累加器

2020-3-9 4:41:44

❯
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索