Results 1 to 11 of 11

Thread: Compressing a Byte array [Resolved]

  1. #1

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Compressing a Byte array [Resolved]

    I have an array of Bytes and I need to compress it, no certain algorithm I just need to create an algorithm that will look for common patterns in the byte array then say replace them for a shorter pateren that is defined at the begining. The only problem is I don't know an algorithm that will definitely work, if someone has already done this it would be a grat help, otherwise I guess i'm going to have to do it from scratch.

    Thanx for any help.
    Last edited by Electroman; Jan 12th, 2003 at 07:41 AM.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  2. #2
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    look up Hoffman encoding on the internet --- it's the most common compression algorithm and is fairly simple as compression algorithms go and you'll find tons of existing code examples.

  3. #3

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Thanx i'll try that.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  4. #4
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    Try using the ZLib.dll, it's very easy to use... it has only 2 functions, compress/decompress

    http://www.winimage.com/zLibDll/
    http://www.gzip.org/zlib/

  5. #5

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Isn't the ZLib.dll for files tho?
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  6. #6

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I think its Huffman you meant not Hoffman. Anyway I found some source code at this link http://www.planet-source-code.com/xq...s/ShowCode.htm, I haven't tryed it just yet but if anyone else wants it theres the link.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  7. #7
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    ZLib.dll compresses data in memory, you can compress anything you whant...

  8. #8
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    Zlib uses the LZ77 algorithm. Information about this algorithm can be found here.
    The LZ77 algorithm isn't proprietary, in contrary with LZW (used by GIF files).

  9. #9
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    Originally posted by Electroman
    Isn't the ZLib.dll for files tho?
    The only two differences between a file and a byte array I can think of is that a file is written to the disk and has a name. A file is still a bytearray imho, even text files.

  10. #10

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I can't find ZLib.dll on my PC so i've downloaded a copy and it won't register, does anyone know why or can someone post a copy they know works cos it might jus be I'v got a dodgy dll.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  11. #11

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Opps my fault, I didn't realise the ZLib procedures were APIs, I was expecting it to contain a class. Oh well thanx, problem solved.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width