문제

How can I convert a byte array from tiff image to a byte array of jpg?

I have the byte array of Tiff image from the web, then how can i use it as jpg without writing a new file?

도움이 되었습니까?

해결책

Byte[] tiffBytes;
Byte[] jpegBytes;

using (MemoryStream inStream = new MemoryStream(tiffBytes))
using (MemoryStream outStream = new MemoryStream())
{
    System.Drawing.Bitmap.FromStream(inStream).Save(outStream, System.Drawing.Imaging.ImageFormat.Jpeg);
    jpegBytes = outStream.ToArray();
}

I didn't try it but it should work. If you are going to save the file last you can just use the save method on the bitmap with a file path instead of a stream.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top