PC Review


Reply
Thread Tools Rate Thread

compression of a string , but must be interoptable someone an idea??

 
 
m.posseth
Guest
Posts: n/a
 
      28th Mar 2005

well let i first explain in more detail what i mean

I would like to compress a string that i am gonna send through a
remoting object that is wrapped in a webservice on a local network
to a VB6 / Delphi win32 forms client


so it should be a algorythm that is availlable in VB.Net and VB6 / Delphi

anyone a good suggestion ???


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      28th Mar 2005
M. Posseth,

There is no VBNet library for that. When you search this newsgroup than you
find a lot of samples.

My expirience with the previous version of this one is good.

http://www.gzip.org/zlib/

While I saw that it supports many platfoms.

I hope this helps a little bit?

Cor


 
Reply With Quote
 
m.posseth
Guest
Posts: n/a
 
      28th Mar 2005
Cor Ligthert wrote:
> M. Posseth,
>
> There is no VBNet library for that. When you search this newsgroup than you
> find a lot of samples.
>
> My expirience with the previous version of this one is good.
>
> http://www.gzip.org/zlib/
>
> While I saw that it supports many platfoms.
>
> I hope this helps a little bit?
>
> Cor
>
>


well i was more thinking about a algorythm that is commonly availlable
on these platforms

Something like huffman three ( a algorythm that is good in plain text
compression ) however did not found a VB.Net version for that one ( or
other managed version, i do not mind to include a C# dll for instance )


my project must consist completely from managed code, but the client
must be capable of working in complete unmanaged code binaries ( for
clients that do not have the framework installed )

Thanks for thinking with me


Michel Posseth




 
Reply With Quote
 
Samuel R. Neff
Guest
Posts: n/a
 
      28th Mar 2005

#ziplib supports huffman compression/decompression.

http://www.icsharpcode.net/OpenSourc...b/Default.aspx

HTH,

Sam


>well i was more thinking about a algorythm that is commonly availlable
>on these platforms
>
>Something like huffman three ( a algorythm that is good in plain text
>compression ) however did not found a VB.Net version for that one ( or
>other managed version, i do not mind to include a C# dll for instance )
>
>
>my project must consist completely from managed code, but the client
>must be capable of working in complete unmanaged code binaries ( for
>clients that do not have the framework installed )
>
>Thanks for thinking with me
>
>
>Michel Posseth


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
 
Reply With Quote
 
Crouchie1998
Guest
Posts: n/a
 
      28th Mar 2005
If you want a compression then I suggest Huffman compression, but there are
no examples of this in VB.NET, but there are in VB6. If you do convert it to
VB.NET then please post the code here.

Here's a link to a VB6 project if you want to convert it:

http://www.planet-source-code.com/vb...11000&lngWId=1

I hope this is of help to you


 
Reply With Quote
 
M. Posseth
Guest
Posts: n/a
 
      28th Mar 2005

Hello Crouchie

Thanks for the link this code should not be so difficult to convert to
VB.Net ,, i was already thinking about the huffman algorythm as i know
that it is verry strong on string values
and as far as i know it should also be possible to make it easily in Delphi


Well i will probably end up in writing one in VB.Net and Delphi as you
just saved me the VB6 version :-)

when it is finished i will post the link were to download it


Michel Posseth






"Crouchie1998" <(E-Mail Removed)> wrote in message
news:e$P0m$(E-Mail Removed)...
> If you want a compression then I suggest Huffman compression, but there

are
> no examples of this in VB.NET, but there are in VB6. If you do convert it

to
> VB.NET then please post the code here.
>
> Here's a link to a VB6 project if you want to convert it:
>
>

http://www.planet-source-code.com/vb...11000&lngWId=1
>
> I hope this is of help to you
>
>



 
Reply With Quote
 
=?Utf-8?B?RGVubmlz?=
Guest
Posts: n/a
 
      29th Mar 2005
Heres a couple of classes the compress and decompress data:

'DATACOMPRESS CLASS - VB.Net
'**********************************************************************************************************
' METHODS:
' CompressBytes(Source ByteArray, Optional Temporay Byte Array
' Compresses ByteArray into Temporary Byte Array or into
ByteArray if Temporary Byte Array not input
'
' DeCompressBytes (Source ByteArray, Original Array Size before
compression as integer, Optional Temporary Byte Array)
' Decompresses ByteArray into Temporary Byte Array or into
ByteArray if Temporary Byte Array not input
'
'***********************************************************************************************************
Imports System.Runtime.InteropServices

Public Class CompressData

'Declare zlib functions "Compress" and "Uncompress" for compressing Byte
Arrays
<DllImport("zlib.DLL", EntryPoint:="compress")> _
Private Shared Function CompressByteArray(ByVal dest As Byte(), ByRef
destLen As Integer, ByVal src As Byte(), ByVal srcLen As Integer) As Integer
' Leave function empty - DLLImport attribute forwards calls to
CompressByteArray to compress in zlib.dLL
End Function
<DllImport("zlib.DLL", EntryPoint:="uncompress")> _
Private Shared Function UncompressByteArray(ByVal dest As Byte(), ByRef
destLen As Integer, ByVal src As Byte(), ByVal srcLen As Integer) As Integer
' Leave function empty - DLLImport attribute forwards calls to
UnCompressByteArray to Uncompress in zlib.dLL
End Function

Public Sub New()
MyBase.New()
End Sub

Public Function CompressBytes(ByRef Data() As Byte, Optional ByRef
TempBuffer() As Byte = Nothing) As Integer
'Compresses Data into a temp buffer
'Returns compressed Data in Data if TempBuff not specified
'Returns Result = Size of compressed data if ok, -1 if compression
failed
Dim OriginalSize As Long = UBound(Data) + 1
'Allocate temporary Byte Array for storage
Dim result As Integer
Dim usenewstorage As Boolean
If TempBuffer Is Nothing Then usenewstorage = False Else
usenewstorage = True
Dim BufferSize As Integer = UBound(Data) + 1
BufferSize = CInt(BufferSize + (BufferSize * 0.01) + 12)
ReDim TempBuffer(BufferSize)
'Compress data byte array
result = CompressByteArray(TempBuffer, BufferSize, Data,
UBound(Data) + 1)
'Store results
If result = 0 Then
If usenewstorage Then
'Return results in TempBuffer
ReDim Preserve TempBuffer(BufferSize - 1)
Else
'Return compressed Data in original Data Array
' Resize original data array to compressed size
ReDim Data(BufferSize - 1)
' Copy Array to original data array
Array.Copy(TempBuffer, Data, BufferSize)
'Release TempBuffer STorage
TempBuffer = Nothing
End If
Return BufferSize
Else
Return -1
End If
End Function
Public Function DeCompressBytes(ByRef Data() As Byte, ByVal Origsize As
Integer, Optional ByRef TempBuffer() As Byte = Nothing) As Integer
'DeCompresses Data into a temp buffer..note that Origsize must be
the size of the original data before compression
'Returns compressed Data in Data if TempBuff not specified
'Returns Result = Size of decompressed data if ok, -1 if not
'Allocate memory for buffers
Dim result As Integer
Dim usenewstorage As Boolean
Dim Buffersize As Integer = CInt(Origsize + (Origsize * 0.01) + 12)
If TempBuffer Is Nothing Then usenewstorage = False Else
usenewstorage = True
ReDim TempBuffer(Buffersize)

'Decompress data
result = UncompressByteArray(TempBuffer, Origsize, Data,
UBound(Data) + 1)

'Truncate buffer to compressed size
If result = 0 Then
If usenewstorage Then
'Return decoompressed data in TempBuffer
ReDim Preserve TempBuffer(Origsize - 1)
Else
'Return decompressed data in original source data file
' Truncate to compressed size
ReDim Data(Origsize - 1)
' Copy Array to original data array
Array.Copy(TempBuffer, Data, Origsize)
'Release TempBuffer STorage
TempBuffer = Nothing
End If
Return Origsize
Else
Return -1
End If
End Function


Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
'Test routines for this class:
'Testing - Remove
'Dim sdata As Byte() = New Byte() {}
'Dim fs As FileStream = New FileStream("C:\Programming\VS-Help Docs\Misc
NewsGroup Articles.doc", FileMode.Open, FileAccess.Read)
'Dim rnew As BinaryReader = New BinaryReader(fs)
' sdata = rnew.ReadBytes(CInt(fs.Length))
' r.Close()
' fs.Close()
'Dim ucomp As Integer = UBound(sdata, 1) + 1
'Dim compsize As Integer = cmp.CompressBytes(sdata)
'Dim uncompsize As Integer = cmp.DeCompressBytes(sdata, ucomp)
'End TEsting

End Class


"M. Posseth" wrote:

>
> Hello Crouchie
>
> Thanks for the link this code should not be so difficult to convert to
> VB.Net ,, i was already thinking about the huffman algorythm as i know
> that it is verry strong on string values
> and as far as i know it should also be possible to make it easily in Delphi
>
>
> Well i will probably end up in writing one in VB.Net and Delphi as you
> just saved me the VB6 version :-)
>
> when it is finished i will post the link were to download it
>
>
> Michel Posseth
>
>
>
>
>
>
> "Crouchie1998" <(E-Mail Removed)> wrote in message
> news:e$P0m$(E-Mail Removed)...
> > If you want a compression then I suggest Huffman compression, but there

> are
> > no examples of this in VB.NET, but there are in VB6. If you do convert it

> to
> > VB.NET then please post the code here.
> >
> > Here's a link to a VB6 project if you want to convert it:
> >
> >

> http://www.planet-source-code.com/vb...11000&lngWId=1
> >
> > I hope this is of help to you
> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
string to byte[] back to string + Compression Failed! jeremyje@gmail.com Microsoft C# .NET 5 10th Feb 2007 07:48 PM
hair-brained code versioning and compression idea =?Utf-8?B?Qm9uag==?= Microsoft C# .NET 13 1st Dec 2004 02:24 AM
String compression =?Utf-8?B?c2tn?= Microsoft C# .NET 8 17th Mar 2004 04:45 PM
Re: simple string compression? Fergus Cooney Microsoft VB .NET 16 8th Oct 2003 02:21 PM
simple string compression? Chris LaJoie Microsoft C# .NET 17 8th Oct 2003 02:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:35 PM.