Hallo,
ich veröffentliche hier aus meinem Trainer Backsprite Editor Rebirth den LZ77 Dekomprimierungscode.
Ich habe ihn mal für euch angepasst, hoffe, dass er so funktioniert.
Code
- Public Class LZ77
- Public Function Decompress(ByVal s As Stream, Optional ByVal offset As Integer = 0) As Byte()
- Dim lzSize As Integer
- Dim DataLeft As Integer
- Dim dcb As Byte
- Dim j As Integer
- Dim br As BinaryReader = New BinaryReader(s)
- br.BaseStream.Position = offset
- lzSize = br.ReadInt32()
- lzSize >>= 8
- DataLeft = lzSize
- Dim Destination(lzSize) As Byte
- On Error Resume Next
- While Not DataLeft <= 0
- ' Read Decode Byte
- dcb = br.ReadByte
- For i = 1 To 8
- Dim x As Byte = CByte((128 / (2 ^ (i - 1))))
- If CInt((dcb And x) >> (2 ^ (i - 1))) = 0 Then
- Destination(j) = br.ReadByte
- j += 1
- DataLeft -= 1
- Else
- Dim rPos As Integer, howManyByte As Integer
- Dim tmp As Integer = br.ReadUInt16
- Dim tmpRev As Integer = (tmp >> 8) + ((tmp And 255) << 8)
- howManyByte = ((tmpRev And 61440) >> 12) + 3
- rPos = (tmpRev And 4095) + 1
- For i2 = 0 To howManyByte - 1
- Destination(j + i2) = Destination(j - rPos + i2)
- DataLeft -= 1
- Next
- j += howManyByte
- End If
- Next
- End While
- Return Destination
- End Function
- End Class
System.IO muss imported werden..
mfG hack!osa