c# 读取二进制文件画灰度图要看你的二进制文件是怎么编码的比如每个数代表什么意思,哪个位

要看你的二进制文件是怎么编码的
比如每个数代表什么意思,哪个位置的数字表示图像的长和宽等

================
你试一下是否符合你的要求
/// <summary>
/// 载入灰度图
/// </summary>
/// <param name="pb">目标 PictureBox 对象</param>
/// <param name="data">字节数组</param>
/// <param name="width">图片宽度</param>
/// <param name="height">图片高度</param>
void LoadPicture(PictureBox pb,byte[] data,int width,int height)
{
Bitmap bmp = new Bitmap(width, height);
Graphics gp = Graphics.FromImage(bmp);
gp.Clear(Color.White);
int t = 0;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++ ,t++)
{
if (t >= data.Length)
{
goto endfor;
}
byte c = data[t];
Color color = Color.FromArgb(c, c, c);
gp.FillRectangle(new SolidBrush(color), x, y, 1, 1);
}
}
endfor:
gp.Save();
pb.Image = bmp;
}