Search code examples
c#.nethttp-compressionimage-conversionjpeg2000

Compress JP2 (JPEG2000) image with a high compression level


After reading Image from database, I need to convert that Image to JP2 (JPEG2000)

Update:

I used FreeImage to convert the image to JP2

   // Load bitmap           
   FIBITMAP dib = FreeImage.LoadEx(imageName);
// Check success
if (dib.IsNull)
{
    MessageBox.Show("Could not load Sample.jpg", "Error");
    return;
}    

// Convert Bitmap to JPEG2000 and save it on the hard disk
FreeImage.Save(FREE_IMAGE_FORMAT.FIF_JP2, dib, "Image.jp2", FREE_IMAGE_SAVE_FLAGS.DEFAULT);

// Unload source bitmap
FreeImage.UnloadEx(ref dib);

Now, I need to compress this image with a high compression level!


Solution

  • I Found The Answer

       // Load bitmap           
       FIBITMAP dib = FreeImage.LoadEx(imageName);
        //
        Check success
        if (dib.IsNull)
        {
            MessageBox.Show("Could not load Sample.jpg", "Error");
            return;
        }    
    
        // Convert Bitmap to JPEG2000 and save it on the hard disk
        FreeImage.Save(FREE_IMAGE_FORMAT.FIF_JP2, dib, "Image.jp2", FREE_IMAGE_SAVE_FLAGS.EXR_PXR24 | FREE_IMAGE_SAVE_FLAGS.EXR_LC);
    
        // Unload source bitmap
        FreeImage.UnloadEx(ref dib);