Page 2 of 3 FirstFirst 123 LastLast
Results 41 to 80 of 82

Thread: ZIP Compression Using Pure Visual Basic

  1. #41
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: ZIP Compression Using Pure Visual Basic

    Actually you can use a sorta inline asm in VB6, Seen it somewhere in a CRC32 class..

  2. #42
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: ZIP Compression Using Pure Visual Basic

    Yeah, I know it too, but it is a trick and not really inline in the real meaning of the word

  3. #43
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: ZIP Compression Using Pure Visual Basic

    Compiled asm I assume?

  4. #44
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: ZIP Compression Using Pure Visual Basic

    Yup, compiled. You just put it in a byte array or similar and then edit memory so that a certain procedure points to the start of the array instead of the actual procedure... I haven't done it myself so I'm not too familiar with the details. I might be a bit wrong, don't really know.


    jian2587: still to make it more clear: you can't make archive program of comparable speed using pure VB6 code only. You can't do that in C/C++ either, so it isn't really an issue. You can make a archive program of comparable speed if you use ASM optimized code to help you. But then we can start wondering why to make an archive program if there are great programs out there already? So... it would be more like a feature addition to a special program and there it is all the same if one will use ASM or VB6 to do it, if VB6 code is fast enough.

    Wonder how long it'll take until we're fully offtopic!


    Edit One last thing: having arguments is never pointless
    Last edited by Merri; Aug 22nd, 2005 at 09:27 AM.

  5. #45
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: ZIP Compression Using Pure Visual Basic

    But it might be a very nice way of having an internal ZIP class that's reasonably fast mmh?

  6. #46
    Lively Member rm_03's Avatar
    Join Date
    Aug 2004
    Posts
    92

    Re: ZIP Compression Using Pure Visual Basic

    probably rm_03 - sorry if not
    No, wasn't me. I don't like that rep stuff.

    I should've had said "lousy performer" in this regards instead, well ... perhaps ...
    Well, on the one hand, we can now create deflated ZIP archives from pure VB. .
    On the other hand you could've avoided a lot of confusion and anger...

    BTW, I bet, with compression method 0 (STORE) I could beat Winzip.

    RhinoBull said what he said, because the code given doesn't prove the original argument; that VB can write ZIP compression in PURE VB.
    Huh? Look at dreamvbs link... Deflate algorithms... ZIP compression method 8... >> pure VB.

    VB6 is of course out of the list, though you can still use the ASM optimized DLL.
    You'll find an Add-In on PSC ("Thunder VB") which will allow you to use inline ASM.

    //edit: @Rinobull: One more thing:
    The question was: "Code to compress a file with ZIP compression",
    not: "Code to compress a file with ZIP compression and Winzip speed and all that stuff".
    I also never intended to create a perfect Winzip clone,
    I just showed that creating a ZIP file in VB is possible, >with compression<.
    (BTW, ZIP compression is the wrong term - ZIP files support many algorithms),
    whereas you first said: "It can't be done in VB", and you didn't say anything about speed.
    That was pretty strange.
    Of course VB can't reach the speed of C and pure ASM. It is taken for granted that you should not use this for a commercial archiving software...

    But having a class to create and extract ZIP archives for the own program is handy IMO.
    You don't have to ship a big DLL for extracting some small files.
    Last edited by rm_03; Aug 22nd, 2005 at 10:14 AM.

  7. #47

  8. #48
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by inventrex
    Well, I don't care about reps, I remember recently when I ask for help within someone else's thread, Penegate came and gave me a neg rep ("I'm sure it will (help), but this post won't.")
    You weren't asking for help if I remember rightly, it was some comment like "I can't do it right now but someone else try it".

    Quote Originally Posted by RhinoBull
    Do you guys mind to stop quoting me, it's enough already. Thanks.
    I don't want to get drawn into any argument, but if you post in a thread and take part in a discussion, then others have a right to quote you IMO.

    Quote Originally Posted by Devion
    Actually you can use a sorta inline asm in VB6, Seen it somewhere in a CRC32 class..
    Quote Originally Posted by Merri
    ...You just put it in a byte array or similar and then edit memory so that a certain procedure points to the start of the array instead of the actual procedure... I haven't done it myself so I'm not too familiar with the details. I might be a bit wrong, don't really know.
    No editing memory needed. As you said, place the precompiled ASM opcodes into a byte array, and use CallWindowProc() to call the procedure. You need to make sure it pops four arguments because that is how many CallWindowProc passes.

  9. #49
    Lively Member rm_03's Avatar
    Join Date
    Aug 2004
    Posts
    92

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by penagate
    You weren't asking for help if I remember rightly, it was some comment like "I can't do it right now but someone else try it".

    I don't want to get drawn into any argument, but if you post in a thread and take part in a discussion, then others have a right to quote you IMO.



    No editing memory needed. As you said, place the precompiled ASM opcodes into a byte array, and use CallWindowProc() to call the procedure. You need to make sure it pops four arguments because that is how many CallWindowProc passes.
    You also could overwrite a dummy function directly with the ASM or with a JMP instruction to the ASM.

  10. #50
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: ZIP Compression Using Pure Visual Basic

    Yah, but you need the ASM first, to do that

    so far as I have seen, precompiled opcodes are the only way to do it. Maybe if you edited the .obj file, but that's overly complex, when this way works

  11. #51
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by rm_03
    BTW, I bet, with compression method 0 (STORE) I could beat Winzip.
    Cheat

  12. #52
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: ZIP Compression Using Pure Visual Basic

    Guys, this thread is for Zip Compression not skull-bashing, use the chit-chat area

    Edit: Good boys! Here's a cookie
    Last edited by Devion; Aug 23rd, 2005 at 06:31 AM.

  13. #53
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: ZIP Compression Using Pure Visual Basic

    Inventrex, I have no idea what that link has to do with the rep I gave you. If you wish to discuss this further then please use the PM system.

  14. #54
    New Member
    Join Date
    May 2005
    Posts
    7

    Re: ZIP Compression Using Pure Visual Basic

    OK, it's fine. Since I don't get what you meant, I'll just delete my useless posts and reduce clutter.

  15. #55
    Member RapchikProgrammer's Avatar
    Join Date
    Jul 2005
    Location
    Hyderabad, Pakistan
    Posts
    61

    Re: ZIP Compression Using Pure Visual Basic

    Firstly, making a zip extractor + compressor is possible! Though quite impractical if not coded with very much care for optimization! Now those who say it cant let me tell u that there has been written a class that can completely decode a jpg file using pure vb! What is a jpg file its basically a 'compressed' picture file! This code uncompresses the file then loads the data! I myself am trying to make a mp3 decoder now a days in pure vb! But as others said we have performance issues! My code takes a loooooong time to only load the mp3 file in binary format! I took the smallest song i can find only 500 kbs and it took like a minute to load on my p4 2.2 ghz! But the jpg compressor is working wonders with lighting fast performance! So making a compressor/extractor is possible but quite impractical cause mp3s and .zips/.rars are files huge in size for vb! So its rather impractical but at the same place it is certainly possible!

  16. #56

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: ZIP Compression Using Pure Visual Basic

    Can someone extract the LZW dynamic with hashing code for me? Or is anyone thinks that there is a better compressor for executables, please give me that code.

  17. #57
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: ZIP Compression Using Pure Visual Basic

    I took the smallest song i can find only 500 kbs and it took like a minute to load on my p4 2.2 ghz!
    Are you talking about actually loading the file into memory? If that takes a minute you are not optimizing your code (Open 'File' for Input as #1?)

  18. #58
    Member RapchikProgrammer's Avatar
    Join Date
    Jul 2005
    Location
    Hyderabad, Pakistan
    Posts
    61

    Re: ZIP Compression Using Pure Visual Basic

    Ok now forgot to mention one thing there (oooops)! Its opening the file as binary taking the value by get function and displaying it in a text box! The displaying code just blows away the speed! I remove the displaying stuff then its really fast so had to mention dat but forgot! So r u guys here planning to make one zip compressor/decompressor or just like talking about it?

  19. #59
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: ZIP Compression Using Pure Visual Basic

    Not sure; I'd be willing to give it a try to make a class-based ZIP/UNZIP.. (Winzip 9 compatible would also require some encryption/decryption routines).

  20. #60
    Lively Member rm_03's Avatar
    Join Date
    Aug 2004
    Posts
    92

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by RapchikProgrammer
    Ok now forgot to mention one thing there (oooops)! Its opening the file as binary taking the value by get function and displaying it in a text box! The displaying code just blows away the speed! I remove the displaying stuff then its really fast so had to mention dat but forgot!
    Wohoo, that'll be a great MP3 decoder.

    Quote Originally Posted by RapchikProgrammer
    So r u guys here planning to make one zip compressor/decompressor or just like talking about it?
    You may read the whole 2 pages of this thread, and check all the posted links.
    Especially the ones by me and dreamvb.
    I also attached my complete deflated ZIP creator project (compile it before using and only compress small files (or use compression level 0), the deflate algorithm sucks!).

    P.S.: The zip was created by it
    Attached Files Attached Files

  21. #61
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: ZIP Compression Using Pure Visual Basic

    So the naming of ZipCreator is kinda incorrect as it can also deflate? (Haven't checked the code yet.. no VB @ work)

  22. #62
    Lively Member rm_03's Avatar
    Join Date
    Aug 2004
    Posts
    92

    Re: ZIP Compression Using Pure Visual Basic

    Deflate is compression, Inflate is decompression.

  23. #63
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: ZIP Compression Using Pure Visual Basic

    The deflate code is pretty poorly coded, even with some simple math changes you can speed it up a lot. Don't know if I bother to do it... already a lot of things going on.

  24. #64

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: ZIP Compression Using Pure Visual Basic

    rm_03, I keep getting oveflow errors when trying to use your program, even on 4 kb files.

  25. #65
    Lively Member rm_03's Avatar
    Join Date
    Aug 2004
    Posts
    92

    Re: ZIP Compression Using Pure Visual Basic

    Run it in the IDE and tell me where the overflow occurs.

  26. #66
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: ZIP Compression Using Pure Visual Basic

    ehh.. yeh Inflate.. - Kinda got 'm mixed up there.

  27. #67
    Addicted Member
    Join Date
    May 2001
    Location
    Montréal, Québec
    Posts
    195

    Re: ZIP Compression Using Pure Visual Basic

    I just wish to add my two cents about language and their capacity (I didn't rapidely find a link in the chit chat forum) and share my knowledge about that.

    If a language have theses 3 simple things:
    1- register like variable (like the long format for the 32 bits)
    2- the "goto" instruction
    3- the "if" instruction

    then you can code anything that come within the time/space complexity of current architecture of software hence the zip format.

    Of course some languages are more suited for such requirement like C/C++ that handle low level byte more easily than vb (in my point of view) but in the end either can do it.

    If a turing machine can do it. Vb / C/C++ / Cobol / Java to name a few can do it. Absolutely. It's only a matter of preferences and skills.

    Sorry if I have bothered you I couldn't just let it go like that.

  28. #68
    Member RapchikProgrammer's Avatar
    Join Date
    Jul 2005
    Location
    Hyderabad, Pakistan
    Posts
    61

    Re: ZIP Compression Using Pure Visual Basic

    Yeah VB Can do it but very slowly! C++ is always the better choice but who wants to build binary trees and go about understanding the huffman algorithm anyway? We got winrar / winzip so wat the hell with creating a zip extractor that takes 2 minutes to compress/decompress a file!

  29. #69

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: ZIP Compression Using Pure Visual Basic

    I think you get overflow errors when you only try to add one file to the zip file.

  30. #70
    Lively Member rm_03's Avatar
    Join Date
    Aug 2004
    Posts
    92

    Re: ZIP Compression Using Pure Visual Basic

    Little bug in the percent calc.
    Attached Files Attached Files

  31. #71
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258

    Re: ZIP Compression Using Pure Visual Basic

    Where can i get the jpeg compression in vb?

  32. #72
    Lively Member rm_03's Avatar
    Join Date
    Aug 2004
    Posts
    92

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by shragel
    Where can i get the jpeg compression in vb?
    http://pscode.com/vb/scripts/ShowCod...50065&lngWId=1

  33. #73
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by RapchikProgrammer
    Yeah VB Can do it but very slowly! C++ is always the better choice but who wants to build binary trees and go about understanding the huffman algorithm anyway? We got winrar / winzip so wat the hell with creating a zip extractor that takes 2 minutes to compress/decompress a file!
    1) Huffman compression isn't that hard to understand. Theres some good sites out there that explain it well (if they are still around).

    2) Why not? Who cares if it takes longer, at least you've learnt something from it..

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  34. #74
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by RapchikProgrammer
    Now those who say it cant let me tell u that there has been written a class that can completely decode a jpg file using pure vb! What is a jpg file its basically a 'compressed' picture file! This code uncompresses the file then loads the data!
    Erm, I wouldn't agree to this either. A JPEG is yes, compressed in a way. The code that you are referring to, doesn't "decompress", it instead just loads the JPEG data. If you understand how a JPEG is compressed, it looses its quality. Kinda hard to explain, but I'm sure you get my point.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  35. #75
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963

    Re: ZIP Compression Using Pure Visual Basic

    I find some of the posts here re-argues the same point over and over. Can we talk about something more constructive? Like what rm_03 did?
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  36. #76
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: ZIP Compression Using Pure Visual Basic

    Agreed, some people just don't read the whole thread when they make their own statement and we end up talking the same points over and over again.

    On the actual topic, I dared to take a quick minor optimization round to the deflate module and I tuned it up by about 10% - the code algorithm structure needs a complete rewrite if anyone wished for a better speed. However, there were many flawed ways to use variables and in-built functions. Here are a few common ones:

    - incorrect datatypes matched against each other -> datatype coercion
    - use of Variant arrays
    - Fix(Number / Value) instead of Number \ Value - the latter is many times faster
    - pointing to same array item multiple times within the same line instead of storing it to a variable
    - using * when + could be used for faster math (ie. Number * 2 -> Number + Number)
    - initializing static values to variables instead of constants with heavy math (such as Variable = 2 ^ 30)

    So yeah, it has a lot of room for improvement.

  37. #77
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963

    Re: ZIP Compression Using Pure Visual Basic

    Merri...I wonder if you wrote any programming books?
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  38. #78
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: ZIP Compression Using Pure Visual Basic

    Nope. I'm "only" a hobbyist programmer.

  39. #79
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,238

    Re: ZIP Compression Using Pure Visual Basic

    Zip uses an algorithm called Deflate to do compression. It does the compression in two steps. The first part (LZ77) should be fairly simple. As it goes along it checks for previous copies of the current data, and if there aren't copies, it produces a literal representation of the data, and if it finds past copies it puts an offset/length pair to the previous copy instead of a literal representation of the data. The second step is huffman compression, which finds which are the most common symbols, and then the more common symbols get shorter bit lengths (so now some symbols will be less than one byte long, which means the data is now being handled at the bit level, not the byte level, and this can get VERY VERY VERY tricky in raw VB code, and so far I've never been able to write a successful huffman algorithm in VB6). So while it should theoretically be possible, the writing of the compression algorithm may very well take up the majority of the time you are spending on writing your program. Not to mention a raw VB6 implementation of the compression algorithm will likely run VERY VERY VERY slowly (due to the complexity of the algorithm, and the fact that VB6 runs MUCH slower than C++, Pascal, Delphi, and 99% of the other programming languages out there).

  40. #80
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: ZIP Compression Using Pure Visual Basic

    I'd like to add my 2 cents here, even though this is not Zip compression (deflate....lz77/huffman).
    It encodes into huffman code, but my tree is not optimized so it will not compress at it's best but it compresses a lot already.
    Also it will not write to file but if you take a quick look at text3.text (once click on Show Binary) this would be what would be in a file (to be read), the only thing missing is the header with how many extra 0 (bits) there is at the end, file length and the characters in order (from the most frequent to less frequent).

    Although winzip uses LZ77 (which should be easier than huffman) and huffman, I'm sure their tree is created different, but the point here is that it can be done, I have shown you huffman code (without the proper tree format) but it is still huffman (compression) code.

    It is not hard to make, but a bit harder to make it fast like winzip.

    Here is the project. I will update it whenever I can.
    Attached Files Attached Files

Page 2 of 3 FirstFirst 123 LastLast

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