|
-
Nov 27th, 2008, 06:36 PM
#7
Thread Starter
Hyperactive Member
Re: Byte Array Compression (Zlib?)
Code:
uncompressed_size = UBound(Data) + 1
ReDim uncompressed_bytes(0 To uncompressed_size)
uncompressed_bytes = Data
compressed_size = 1.01 * uncompressed_size + 20
ReDim compressed_bytes(0 To compressed_size)
lReturn = compress(compressed_bytes(0), compressed_size, _
uncompressed_bytes(0), _
uncompressed_size)
Select Case lReturn
Case Z_OK
ReDim Preserve compressed_bytes(0 To compressed_size)
Debug.Print uncompressed_size & " | " & UBound(compressed_bytes)
Erase uncompressed_bytes
Case Z_MEM_ERROR
Err.Raise vbObjectError + Abs(lReturn), "UncompressString", _
"Insufficient memory to uncompress string"
Case Z_BUF_ERROR
Err.Raise vbObjectError + Abs(lReturn), "UncompressString", _
"Insufficient space in output buffer to uncompress string"
Case Z_DATA_ERROR
Err.Raise vbObjectError + Abs(lReturn), "UncompressString", _
"Cannot uncompress corrupt data"
Case Else
Err.Raise vbObjectError + Abs(lReturn), "UncompressString", _
"Unknown error during uncompress operation"
End Select
This one may be full of errors, because i kinda did it in a frenzy, the previous one i posted doesnt seem to compress enough for me, however this one seems to do it the compression i need, but theres a memory leak or something somewhere, and it causes the IDE to act up, then crash.
If I run this process very fast multiple times i end up getting "out of memory" errors, and basic things like the ".text" of a textbox failing to initialize, then Vb6.exe crashing out.
The current way i'm sending things is Im compressing an actual string containing the numbers i.e.(255,222,92,37,29,48,141...and so on) and then convertng the compressed into a byte array and sending the bytes, But its sluggish, and sometimes starts getting mangled up, so i figure sending the raw bytes compressed would be easier
-
and i'm using the newest zlib.dll i got off the zlib website
http://www.zlib.net/zlib123-dll.zip
Last edited by Teseng; Nov 27th, 2008 at 06:45 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|