Results 1 to 6 of 6

Thread: compression through code/api?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Hi,

    I was wondering if it's possible to compress/decompress files without using dll's or controls?

    It seems that all the code out there for compression through VB utiltizes dll's or controls. Is there a reason for this? Is it not possible to do compression through code or api using VB? Would that be something that can only be done in C++?

    Any help would be appreciated..

    Dan

  2. #2
    Guest
    I believe there are programs on http://www.planet-source-code.com that are able to zip files without having to use a control or activex dll. Try searching for "Winzip" or "Compression".

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    There's a few reasons why C++ is actually easier to write compression code in (not speed):

    1. Pointers - find data sections easily
    2. Much better memory handling
    3. Binary file handing

    And yes, it is faster. Take a look at ZLibDLL (do a search on AV) for what is pretty much a standard. Also, if there is any code for BZip2, use that, because it is technically more advanced and creates smaller files.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Addicted Member bbosh's Avatar
    Join Date
    Oct 2000
    Location
    Hell (AKA New Mexico)
    Posts
    186

    compression is easy

    fooled you. actually, compressing is easy like i said, good compression is not. this is not the zip format, but it's easy to do:
    Look for a sequence of characters that occurs two or more times, and is at least two characters long.
    In the previous sentance, there are the following:
    lo: LOok LOng
    or: fOR OR mORe
    two : TWO TWO
    characters : twice (Remember to include spaces if possible)

    Now, lets subsitute a ! for lo ? for or, a > for two and a < for characters.
    !ok f? a sequence of<that occurs>? m?e times, and is at least><!ng.
    Original sentance: 102 characters
    Compressed: 67 characters.
    That's 35% compression. Plus, I only looked for obvious sequences, not every other letter or every third. Unfortuently, you need to include the susbstitioun code as well. It may look like this:
    FORMAT: REPLACEMENT SYMBOL - LENGTH OF TEXT (to avoid CRLF) - TEXT. when header wears out, text begins.
    !2lo?2or>5 two <10characters!ok f? a sequence of<that occurs>? m?e times, and is at least><!ng.
    While it's not as impressive now, its still damn good for one sentance.

    not practical for this example, but the most common are:
    " the " chr$(13)+chr$(10) " a " " i " " an ", all minus the quotes of course.

    Thats compression 101
    Brian
    Programming: VB5 Pro (SP3) - QBasic 1.1,4.5
    Internet: HTML 4, CSS, JavaScript
    Visit AltInt.com!

  5. #5
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049
    [quote]There's a few reasons why C++ is actually easier to write compression code in (not speed):

    1. Pointers - find data sections easily
    2. Much better memory handling
    3. Binary file handing
    [quote]

    Okay.. with point 1 i have to agree.. VB has no real pointer operation.

    point 2.. Learn to program }

    point 3.. Open "Bla.bin" for BINARY as #1
    VB has Binary file handling too (Since gwBasic

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Er...I know that. What I meant was, binary files in C++ are a lot easier, because you can read/write things faster, easier, and more efficiently. Plus you can cheat and since you have control over the alignment of your data structures you can massage them into different objects, for example turn a struct into an int* .
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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