JPEG 2000 support in C#.NET

Gordon Thompson picture Gordon Thompson · Feb 26, 2009 · Viewed 22.9k times · Source

It seems that .NET can't open JP2 (Jpeg 2000) files using the GDI library. I've searched on google but can't find any libraries or example code to do this.

Anybody got any ideas? I don't really want to pay for a library to do it unless I have to..

Answer

Gordon Thompson picture Gordon Thompson · Jul 21, 2010

Seems like we can do it using FreeImage (which is free)

FIBITMAP dib = FreeImage.LoadEx("test.jp2");
//save the image out to disk    
FreeImage.Save(FREE_IMAGE_FORMAT.FIF_JPEG, dib, "test.jpg", FREE_IMAGE_SAVE_FLAGS.JPEG_QUALITYNORMAL);
//or even turn it into a normal Bitmap for later use
Bitmap bitmap = FreeImage.GetBitmap(dib);