We have nothing built into .Net, but you can use FreeImage , which is a free library that can do this.
Here is an example of this .
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);
To convert from byte stream u, you can try the following:
byte[] myByte = new byte[10]; MemoryStream theMemStream = new MemoryStream(); theMemStream.Write(myByte, 0, myByte.Length); FreeImageBitmap fbm = FreeImageBitmap.FromStream(theMemStream); fbm.Save("text.jpg",FREE_IMAGE_STREAM.FIF_JPEG);
source share