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. JPEG loseless and lossy compression

JPEG loseless and lossy compression

Scheduled Pinned Locked Moved C#
help
8 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.
  • D Offline
    D Offline
    Darmi
    wrote on last edited by
    #1

    Hi, I want to implement JPEG loseless and lossy compression. Can anyone please help me. Darmi

    C S 2 Replies Last reply
    0
    • D Darmi

      Hi, I want to implement JPEG loseless and lossy compression. Can anyone please help me. Darmi

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      There are many 'JPEG' compressions. The most common one is the lossy one supported by GDI+. Creating files using this compression in C# is trivial. There are also a number of 'lossless' compressions, including JPEG 2000, JPEG lossless, etc. For JPEG 2000, I use the Atalasoft imaging library ( the J2000 stuff is an add on, and not cheap ). There are no free implimentations of J2000 that I know of, there is a JPEG lossless dll from HP, but I never actually got around to using it, I just found it in my search for a lossless compression supported by DICOM.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      D 1 Reply Last reply
      0
      • C Christian Graus

        There are many 'JPEG' compressions. The most common one is the lossy one supported by GDI+. Creating files using this compression in C# is trivial. There are also a number of 'lossless' compressions, including JPEG 2000, JPEG lossless, etc. For JPEG 2000, I use the Atalasoft imaging library ( the J2000 stuff is an add on, and not cheap ). There are no free implimentations of J2000 that I know of, there is a JPEG lossless dll from HP, but I never actually got around to using it, I just found it in my search for a lossless compression supported by DICOM.

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        D Offline
        D Offline
        Darmi
        wrote on last edited by
        #3

        Thanks Christian Graus, But i need the implementation in C# or the algorithm to implement this compression techniques. Thanks, Darmi

        C 1 Reply Last reply
        0
        • D Darmi

          Thanks Christian Graus, But i need the implementation in C# or the algorithm to implement this compression techniques. Thanks, Darmi

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          I see. Well, I want a Ferrarri. Doesn't mean I can have one. Like I said, there are no C# implimentations for JPEG lossless that I know of. JPEG 2000, there are definately no free implimentations. The cheapest I found was Atalasoft, it's about $2000 plus the cost of their core library. It's very good, I use it.

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          1 Reply Last reply
          0
          • D Darmi

            Hi, I want to implement JPEG loseless and lossy compression. Can anyone please help me. Darmi

            S Offline
            S Offline
            Seishin
            wrote on last edited by
            #5

            Image image; ... Bitmap bmp = new Bitmap(image); ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); ImageCodecInfo ici = null; foreach(ImageCodecInfo codec in codecs) { if(codec.MimeType == "image/jpeg") ici = codec; } EncoderParameters ep = new EncoderParameters(); long quality = (long)100; // 0-lossy ... 100-loseless ep.Param[0] = new EncoderParameter(Encoder.Quality, quality); bmp.Save(fileName, ici, ep);

            life is study!!!

            C D 2 Replies Last reply
            0
            • S Seishin

              Image image; ... Bitmap bmp = new Bitmap(image); ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); ImageCodecInfo ici = null; foreach(ImageCodecInfo codec in codecs) { if(codec.MimeType == "image/jpeg") ici = codec; } EncoderParameters ep = new EncoderParameters(); long quality = (long)100; // 0-lossy ... 100-loseless ep.Param[0] = new EncoderParameter(Encoder.Quality, quality); bmp.Save(fileName, ici, ep);

              life is study!!!

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              No, you are totally wrong. Even at 100, a JPEG is lossy. It's just less so. And, as I said in my answer, there are many JPEG formats, including lossless ones. They are not supported by .NET, only the common lossy JPEG format is.

              Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              S 1 Reply Last reply
              0
              • C Christian Graus

                No, you are totally wrong. Even at 100, a JPEG is lossy. It's just less so. And, as I said in my answer, there are many JPEG formats, including lossless ones. They are not supported by .NET, only the common lossy JPEG format is.

                Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                S Offline
                S Offline
                Seishin
                wrote on last edited by
                #7

                Christian Graus wrote:

                No, you are totally wrong

                not totally I guess..

                Christian Graus wrote:

                Even at 100, a JPEG is lossy

                maybe, but a lot less lossy than Image.Save()

                life is study!!!

                1 Reply Last reply
                0
                • S Seishin

                  Image image; ... Bitmap bmp = new Bitmap(image); ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); ImageCodecInfo ici = null; foreach(ImageCodecInfo codec in codecs) { if(codec.MimeType == "image/jpeg") ici = codec; } EncoderParameters ep = new EncoderParameters(); long quality = (long)100; // 0-lossy ... 100-loseless ep.Param[0] = new EncoderParameter(Encoder.Quality, quality); bmp.Save(fileName, ici, ep);

                  life is study!!!

                  D Offline
                  D Offline
                  Darmi
                  wrote on last edited by
                  #8

                  Hai Seishin, I have tried this method. But i read some documents indicating two different algorithms for implementing lossy and losseless - huffman algorithm.. something like this. If we can implement lossy and loseless in the above method, then why its said that there are two different algorithms for each. Morover, i came to know that JPEG is lossy itself, but loseless have different format other than .jpg. Am i correct? Please help me. Darmi

                  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