このコードを実行したい
Bitmap grayImage = (Bitmap)img.Clone();
for (int x = 0; x < arr.GetLength(0); x++)
{
for (int y = 0; y < arr.GetLength(1); y++)
{
int col = arr[x, y];
Color grau = Color.FromArgb(col, col, col);
grayImage.SetPixel(x, y, grau);
}
}
コードを実行すると、次の行で例外が発生します: grayImage.SetPixel(x, y, grau);
例外の詳細は次のとおりです。
System.Runtime.InteropServices.ExternalException は、ほとんどの場合例外です。Message="GDI+ で一般的なエラーが発生しました。" Source="System.Drawing" ErrorCode=-2147467259 StackTrace: System.Drawing.Bitmap.SetPixel(Int32 x, Int32 y, Color color) at Metalldetektor.Bild.ArrToPic(Int32[,] arr, Image img) in D: \Documents\Visual Studio 2008\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Bild.cs:D:\Documents\Visual Studio 2008\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1 の Metalldetektor.Form1.button2_Click(オブジェクト送信者、EventArgs e) の 44 行目。 cs:58行目 System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button,
どうすればいいのかわからないので助けてください!