【发布时间】:2014-01-02 18:20:02
【问题描述】:
我使用此代码将数据从 bmp 复制到 c# 中的结构数组, 运行程序时显示消息“参数无效”
struct pix //structure for pixel in bmp image
{
public byte b;//Red
public byte g;//Green
public byte r;//Blue
};
private void button1_Click(object sender, EventArgs e)
{
byte[] bmp = File.ReadAllBytes("D:\\x.bmp");
Bitmap img = new Bitmap(openFileDialog1.FileName);
pix[,] bmpdata = new pix[img.Height-1, img.Width-1];
Array.Copy(bmp, 54, bmpdata, 0, (bmp.Length)-54);
}
程序出了什么问题,有没有其他方法可以复制,我需要在图片框中显示新的数组?
【问题讨论】:
-
哪一行在说“参数无效”?我想你有` Bitmap img = new Bitmap(openFileDialog1.FileName);字符串文件名 = openFileDialog1.FileName;` 向后。
标签: c# arrays struct copy picturebox