auto 发表于 2012-12-3 10:21:59

在论坛(英文)论坛找了一个压缩算法。。但是一运行就报错,不知道怎么回事

本帖最后由 auto 于 2012-12-3 10:24 编辑

在论坛(英文)论坛找了一个压缩算法。。但是一运行就报错,不知道怎么回事, 或者谁有比较好用的压缩算法,用来压缩富文本的


原文链接:http://www.autoitscript.com/forum/topic/112273-lzma-compression-udf/
; ------------------------------------------------------------------
; LZMA Data Compression UDF
; Purpose: Demonstrate the usage of LZMA UDF
; Author:Ward
; ------------------------------------------------------------------


#include "LZMA.DLL.AU3" ; Delete this line to use the external LZMA.DLL file
#include "LZMA.AU3"
#RequireAdmin

LzmaInit()
;Demo0()
;Demo1()
;Demo2()
LzmaExit()

Func Demo0()
        Local $Source = Binary("LZMALZMALZMALZMALZMALZMALZMALZMALZMALZMA")
        Local $Compressed = LzmaEnc($Source)
        Local $Decompressed = LzmaDec($Compressed)
        Output($Source, $Compressed, $Decompressed)
EndFunc

Func Demo1()
        Local $String = FileRead(@ScriptFullPath)
        Local $Source = StringToBinary($String)

        Local $Timer = TimerInit()
        Local $Compressed = LzmaEnc($Source)
        If @Error Then
                MsgBox(0, 'LZMA Demo', "Compress Fail (Unable To Compress ?)")
                Exit
        EndIf
        Local $Decompressed = BinaryToString(LzmaDec($Compressed))

        Output($Source, $Compressed, $Decompressed, $Timer)
EndFunc


Func Demo2()
        Local $FileName = FileOpenDialog("Select file to test (don't too big)", @ScriptDir, "Any File (*.*)")
        If $FileName = "" Then Exit

        If FileGetSize($FileName) > 50 * 1024 * 1024 Then
                If MsgBox(4, "LZMA Demo", "File size is larger than 50mb, really want to try it?") = 7 Then Exit
        EndIf       

        Local $File = FileOpen($FileName, 16)
        Local $Source = FileRead($File)
        FileClose($File)

        Local $Timer = TimerInit()
        Local $Compressed = LzmaEnc($Source)
        If @Error Then
                MsgBox(0, 'LZMA Demo', "Compress Fail (Unable To Compress ?)")
                Exit
        EndIf
        Local $Decompressed = LzmaDec($Compressed)

        Output($Source, $Compressed, $Decompressed, $Timer)
EndFunc


Func Output($Source, $Compressed, $Decompressed, $Timer = 0)
        Local $Msg = "Source Size: " & BinaryLen($Source) & @LF
        $Msg &= "Compressed Size: " & BinaryLen($Compressed) & @LF
        $Msg &= "Decompression Succeed: " & ($Source = $Decompressed) & @LF
        $Msg &= "Ratio: " & Round(BinaryLen($Compressed)/BinaryLen($Source), 4) * 100 & "%" & @LF
        If $Timer Then $Msg &= "Time: " & Round(TimerDiff($Timer)) & " ms"
        MsgBox(0, 'LZMA Demo', $Msg)
EndFunc

annybaby 发表于 2012-12-3 11:05:21

本帖最后由 annybaby 于 2012-12-3 11:38 编辑

回复 1# auto


    什么情况??无图??


测试多个文件,都没问题~~~

auto 发表于 2012-12-3 11:57:06

系统直接报错。。可能跟我的系统是64位有关系。。 我用的win7 SP1 64位

auto 发表于 2012-12-3 11:58:08

回复 2# annybaby


    问题签名:
问题事件名称:        BEX64
应用程序名:        autoit3_x64.exe
应用程序版本:        3.3.9.0
应用程序时间戳:        4f2db4a1
故障模块名称:        StackHash_3ada
故障模块版本:        0.0.0.0
故障模块时间戳:        00000000
异常偏移:        00000000005ee150
异常代码:        c0000005
异常数据:        0000000000000008
OS 版本:        6.1.7601.2.1.0.256.1
区域设置 ID:        2052
其他信息 1:        3ada
其他信息 2:        3ada4e6566862814eace3e2e61a74288
其他信息 3:        0321
其他信息 4:        0321c95fc28f81f0b310e3bd96ba9be9

netegg 发表于 2012-12-3 15:15:32

压的是什么,原文件转成二进制再试试
页: [1]
查看完整版本: 在论坛(英文)论坛找了一个压缩算法。。但是一运行就报错,不知道怎么回事