|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
compression of a string , but must be interoptable someone an idea ??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 ??? 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 Cor Ligthert wrote:
Show quoteHide quote > M. Posseth, well i was more thinking about a algorythm that is commonly availlable > > 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 > > 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 #ziplib supports huffman compression/decompression.
http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx HTH, Sam Show quoteHide quote >well i was more thinking about a algorythm that is commonly availlable B-Line is now hiring one Washington D.C. area VB.NET >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 developer for WinForms + WebServices position. Seaking mid to senior level developer. For information or to apply e-mail resume to sam_blinex_com. 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/scripts/ShowCode.asp?txtCodeId=11000&lngWId=1 I hope this is of help to you 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" <crouchie1***@discussions.microsoft.com> wrote in message http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=11000&lngWId=1news:e$P0m$6MFHA.3356@TK2MSFTNGP12.phx.gbl... > 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: > > Show quoteHide quote > > I hope this is of help to you > > 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 Show quoteHide quote "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" <crouchie1***@discussions.microsoft.com> wrote in message > news:e$P0m$6MFHA.3356@TK2MSFTNGP12.phx.gbl... > > 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/scripts/ShowCode.asp?txtCodeId=11000&lngWId=1 > > > > I hope this is of help to you > > > > > > >
FileSystemObject vs System.IO.File
Array of Hash Tables Query database in VB.NET Create ListView columns dynamically from XML record locking with DBF (visual basic) table in ADO OLEDB in VB.NET Set Desktop Progress Bar Setup problem How to have embeded pictures in a project need ideas - how to determine when another machine has persisted a file |
|||||||||||||||||||||||