转换图像< Rgba32>使用ImageSharp转换为Byte [] [英] Convert Image<Rgba32> to Byte[] using ImageSharp
本文介绍了转换图像< Rgba32>使用ImageSharp转换为Byte []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用ImageSharp库将图像转换为字节数组?
How can I convert an image to array of bytes using ImageSharp library?
ImageSharp库还可以基于EXIF方向建议/提供RotateMode和FlipMode吗?
Can ImageSharp library also suggest/provide RotateMode and FlipMode based on EXIF Orientation?
推荐答案
如果您希望将原始像素转换为byte[]
,请执行以下操作.
If you are looking to convert the raw pixels into a byte[]
you do the following.
var bytes = image.SavePixelData()
如果您想将编码流转换为byte[]
(我怀疑您正在寻找的是).你这样做.
If you are looking to convert the encoded stream as a byte[]
(which I suspect is what you are looking for). You do this.
using (var ms = new MemoryStream())
{
image.Save(ms, imageFormat);
return ms.ToArray();
}
这篇关于转换图像< Rgba32>使用ImageSharp转换为Byte []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文