Valhalla Legends Forums Archive | Visual Basic Programming | Decompressing a 24-bit TGA file.

AuthorMessageTime
BinaryzL
I am looking for VB6 code that will decompress a 24-bit tga file if anyone has it can you please post it.
May 16, 2004, 10:21 PM
UserLoser.
Thought I told someone you can find it on Google, because, I know I did!
[code]
Private Function DecompressTGA(RLEStream() As Byte, Bits As Long, Höhe As Long, Breite As Long) As Byte()
Dim InitSize As Long
Dim Temp() As Byte
Dim n As Long
Dim K As Boolean
Dim B As Long
Dim l As Long
Dim fertig As Long
Dim z As Long
Dim Länge As Long
Dim Byteanzahl As Long

Byteanzahl = Bits / 8
InitSize = CLng(Höhe * Breite * Byteanzahl)
ReDim Temp(0 To InitSize)
Do While fertig < InitSize
If l > UBound(RLEStream) Then GoTo Ende
z = 0
If RLEStream(l) > 127 Then
n = RLEStream(l) - 127
For B = 0 To n - 1

CopyMemory Temp(fertig), RLEStream(l + 1), Byteanzahl
fertig = fertig + Byteanzahl

Next B
K = True
Else
n = RLEStream(l) + 1
Länge = n * Byteanzahl

CopyMemory Temp(fertig), RLEStream(l + 1), Länge

K = False
z = z + Länge

fertig = fertig + z
End If
If K = True Then
l = Byteanzahl + 1 + l
n = z + (n * Byteanzahl) + 1
Else
l = (n * Byteanzahl + 1) + l
n = z + n
End If
Loop
Ende:
DecompressTGA = Temp
End Function
[/code]
May 16, 2004, 10:53 PM
BinaryzL
Hah thanks I looked and couldn't find anything, I guess my google searching skills are bad.

For the people wanting to use this:

Höhe is Height.
Breite is Width.
Fertig is Finished.
Länge is Length.
Byteanzahl is actually byte amount.
May 17, 2004, 3:34 PM

Search