要获取TIFF图像的字节数组并将其转换为System.Drawing.Image对象,您可以遵循以下步骤:
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
public byte[] ConvertImageToByteArray(string imagePath)
{
using (Image image = Image.FromFile(imagePath))
{
using (MemoryStream ms = new MemoryStream())
{
image.Save(ms, ImageFormat.Tiff);
return ms.ToArray();
}
}
}
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
public Image ConvertByteArrayToImage(byte[] byteArray)
{
using (MemoryStream ms = new MemoryStream(byteArray))
{
return Image.FromStream(ms);
}
}
这样,您就可以在需要时调用这两个函数,将TIFF图像转换为字节数组,并将字节数组转换回System.Drawing.Image对象。
没有搜到相关的沙龙
领取专属 10元无门槛券
手把手带您无忧上云