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#
  4. C# compression

C# compression

Scheduled Pinned Locked Moved C#
csharp
3 Posts 3 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.
  • G Offline
    G Offline
    GauravKP
    wrote on last edited by
    #1

    I have a byte[] of jpg image of size 1.5 kb, is there any method in C# to compress this byte[] further. I tried by GZip class but actually its size has increased, i found that GZip class is unable to compress jpg image byte[]. Can anyone suggest me any more method. This is actually needed bcoz the image has to be stored i smart card application and i have limited scope to allot space. Thanx

    L A 2 Replies Last reply
    0
    • G GauravKP

      I have a byte[] of jpg image of size 1.5 kb, is there any method in C# to compress this byte[] further. I tried by GZip class but actually its size has increased, i found that GZip class is unable to compress jpg image byte[]. Can anyone suggest me any more method. This is actually needed bcoz the image has to be stored i smart card application and i have limited scope to allot space. Thanx

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Of course a general compression as used in ZIP can't do any better on images than the specialized JPEG compression that knows and understands what it is dealing with. If you want a smaller file, you need to throw away some of the information; here are two ideas: - reduce the number of colors - reduce the image size Yes, I know, both will reduce image quality as well. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


      1 Reply Last reply
      0
      • G GauravKP

        I have a byte[] of jpg image of size 1.5 kb, is there any method in C# to compress this byte[] further. I tried by GZip class but actually its size has increased, i found that GZip class is unable to compress jpg image byte[]. Can anyone suggest me any more method. This is actually needed bcoz the image has to be stored i smart card application and i have limited scope to allot space. Thanx

        A Offline
        A Offline
        Alan Balkany
        wrote on last edited by
        #3

        For extreme requirements like this, it may justify splitting the byte array into chunks, and using a custom compression algorithm for each chunk. For example, you may find a run of several hundred pixels with the same value, which would compress nicely with run-length encoding: The single pixel value plus a repetition factor. Other chunks may have different types of regularity you can exploit, such as a repeated block pattern. The compressed image will end up as a list of chunks, each with a byte identifier (that gives the compression type for that chunk) followed by that chunk's data. To decompress, go through the chunks, read the byte identifier, then execute the corresponding code to reconstruct that chunk.

        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