[英]Convert image to array 2d
I'm need to convert an image to 2D array but I don't know how. 我需要将图像转换为2D数组,但我不知道如何。 I managed to convert it into 1D array so far.
到目前为止,我设法将其转换为一维数组。
public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
MemoryStream ms = new MemoryStream();
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
return ms.ToArray();
}
Image image = Image.FromFile("c:\\p01.png");
byte[] mm = imageToByteArray(image);
See the answer to this question: How to convert 1D byte array to 2D byte array which holds a bitmap? 请参阅以下问题的答案: 如何将1D字节数组转换为包含位图的2D字节数组?
Basically, you want to pass image.Width
to the ConvertArray
function mentioned in the accepted answer that converts 1D array to 2D array. 基本上,您想将
image.Width
传递给已接受的答案中提到的ConvertArray
函数,该函数将1D数组转换为2D数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.