BriefLZPack

Syntax:

Result=BriefLZPack(Source,Destination,Length,CallBack)

Parameters:

Source

=

Adress of Source Memory Block to compress

Destination

=

Adress of Destination Memory Block to store compressed Memoryblock (Must be allocated before)

Length

=

Length of Mthe SAource-MemoryBlock to compress

CallBack

=

Adress of a CallbackProcedure or NULL for no CallBack


Return Values:

Result

=

is the new size of the packed memory-Block in Bytes


Description:

Compresses a Block of memory


Example:



Procedure TestMe(Parameter)
 Debug Parameter
 ;Beep_(Parameter,50)
EndProcedure 

Filename.s="C:\bibeltext.txt" ; a 4,3 mb textfile
Filename.s="C:\Bitmap.bmp"; a 2,3mb screenshot
;Filename.s="C:\pbor\Datenbank Ohne Mod.pbor"
Filename2.s="C:\test.pck"
Filename3.s="C:\test2.bmp"




If ReadFile(1,Filename.s)
 l=Lof()
 Source=AllocateMemory(l)
 ReadData(Source,L)
 CloseFile(1)

 ;Debug PeekS(Source,40)
 Debug "len of File="+Str(l)
 Dest=AllocateMemory(L) ;genausoviel Destinationram allokieren
 t1=GetTickCount_()
 Result=BriefLZPack(Source,Dest,L,@TestMe())
 t2=GetTickCount_()
 Debug "time for packing "+Str(L) +" bytes to "+Str(result)+" bytes =" + Str(t2-t1)+" msec.s"
 ;Debug PeekS(DEST,40)
 ;write down to Disk
 If CreateFile(0,Filename2.s)
  WriteData(Dest,result)
  CloseFile(0)
 EndIf
 
 FreeMemory(Dest)
 If ReadFile(1,Filename2.s)
  l2=Lof()
  Dest=AllocateMemory(l2)
  ReadData(Dest,L2)
  CloseFile(1)
 EndIf
 
 ;allocate some memory For the depacking Functions
 DeSource=AllocateMemory(l+4)

 t1=GetTickCount_()
 result= BriefLZDePack(Dest, DeSource,L,@TestMe())
 t2=GetTickCount_()
 Debug "time for Depacking to "+Str(result)+" bytes =" + Str(t2-t1)+" msec.s"
 Debug result
 If CreateFile(0,Filename3.s)
  WriteData(Desource,result)
  CloseFile(0)
 EndIf
 ;Debug PeekS(DeSource,40)
 ;Release Memory
 FreeMemory(Desource)
 FreeMemory(Source)
 FreeMemory(Dest)
 
EndIf

Remarks:

tested with Win9x + NT/2k/XP

If you don't need a Callback (for showing percentage while packing) , put a NULL as Parameter .



Supported OS:   Windows