Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to write a existing bigger binary file into small/compact binary file in C.

How to write a existing bigger binary file into small/compact binary file in C.

Scheduled Pinned Locked Moved C / C++ / MFC
csharptutorial
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cancerion
    wrote on last edited by
    #1

    I have a binary file of size 3GB. I want to reduce the size using some coding in C to write another binary file. Please suggest/provide a way to write compact binary file. TO read this file i need to use C#. Thanks, Sachin

    G G A R 4 Replies Last reply
    0
    • C cancerion

      I have a binary file of size 3GB. I want to reduce the size using some coding in C to write another binary file. Please suggest/provide a way to write compact binary file. TO read this file i need to use C#. Thanks, Sachin

      G Offline
      G Offline
      ghle
      wrote on last edited by
      #2

      WinZip(3GB_Filename, 2GB_Filename);

      ? :) Seriously, it depends on what is contained in the 3GB binary file. Is it even compressible? If it contains lots of NULLS, for example, change the NULL bytes to a single NULL followed by a count of how many there are. A string of 10 NULLS would turn into a single NULL and a byte with the number 10 in it, saving 8 bytes. Reading the file in, you would simply reverse the process. 1,2,3,4,5,0,0,0,0,0,0,0,0,0,0,1,2,3,a,b,c,0,0,0,0,d,e,0,f,ff (30 bytes) Becomes 1,2,3,4,5,0,a,1,2,3,a,b,c,0,4,d,e,0,1,f,ff (21 bytes) Alternatively, implement one of the Open Source Zip and Unzip routines in your C and C# code, as appropriate.

      Gary

      1 Reply Last reply
      0
      • C cancerion

        I have a binary file of size 3GB. I want to reduce the size using some coding in C to write another binary file. Please suggest/provide a way to write compact binary file. TO read this file i need to use C#. Thanks, Sachin

        G Offline
        G Offline
        GAJERA
        wrote on last edited by
        #3

        check this library. http://zlib.net/[^] use following function from library for compress binary file. deflateInit deflate deflateEnd

        1 Reply Last reply
        0
        • C cancerion

          I have a binary file of size 3GB. I want to reduce the size using some coding in C to write another binary file. Please suggest/provide a way to write compact binary file. TO read this file i need to use C#. Thanks, Sachin

          A Offline
          A Offline
          Aescleal
          wrote on last edited by
          #4

          I've used (libbzip2[^]) in the past with some success at shrinking certain types of binary file. Hopefully there's some repetition in it or whatever you try isn't going to be able to do much to shrink it. Cheers, Ash

          1 Reply Last reply
          0
          • C cancerion

            I have a binary file of size 3GB. I want to reduce the size using some coding in C to write another binary file. Please suggest/provide a way to write compact binary file. TO read this file i need to use C#. Thanks, Sachin

            R Offline
            R Offline
            rp_suman
            wrote on last edited by
            #5

            Hope below links will help you: fastest c++ file compression library available[^] Cabinet File (*.CAB) Compression and Extraction[^]

            -- "Programming is an art that fights back!"

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups