ich dieses Stück CodeC# externe Ausnahme in GDI +
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);
}
}
ausgeführt werden soll, wenn ich den Code ausführen ich eine Ausnahme in dieser Zeile: grayImage.SetPixel (x, y, grau);
Hier sind die Ausnahmedetails:
System.Runtime.InteropServices.ExternalException Wurde nicht Behandelt. Message = "Ein allgemeiner Fehler ist in GDI + aufgetreten." Source = "System.Drawing" Error-Code = -2147467259 Stacktrace: bei System.Drawing.Bitmap.SetPixel (Int32 x, y Int32, Farbe Farbe) bei Metalldetektor.Bild.ArrToPic (Int32 [,] arr, Bild img) in D: \ Dokumente \ Visual Studio 2008 \ Projekte \ WindowsFormsApplication1 \ WindowsFormsApplication1 \ Bild.cs: Zeile 44 bei Metalldetektor.Form1.button2_Click (Objekt Absender, EventArgs e) in D: \ Dokumente \ Visual Studio 2008 \ Projects \ WindowsFormsApplication1 \ WindowsFormsApplication1 \ Form1.cs: Zeile 58 bei System.Windows.Forms.Control.OnClick (EventArgs e) bei System.Windows.Forms.Button.OnMouseUp (MouseEventArgs mevent) bei System.Windows.Forms.Control. WmMouseUp (Nachricht & m, Maustasten, Int32 Klicks) bei System.Windows.Forms.Control.WndProc (Message & m) bei System.Windows.Forms.ButtonBase.WndProc (Message & m) bei System.Windows.Forms.Button.WndProc (Message & m) an System.Windows.Forms.Control.ControlNativeWindow.WndProc (Message & m) bei System.Windows.Forms.NativeWindow.DebuggableCallback (IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) bei System.Windows.Forms.UnsafeNativeMethods. DispatchMessageW (MSG & msg) bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop (Int32 DwComponentID, Grund Int32, Int32 pvLoopData) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner (Int32 Grund, ApplicationContext Kontext) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop (Int32 Grund, ApplicationContext Kontext) bei Metalldetektor.Program.Main() in D: \ Dokumente \ Visual Studio 2008 \ Projekte \ WindowsFormsApplication1 \ WindowsFormsApplication1 \ Program.cs: Zeile 19 bei System.AppDomain._nExecuteAssembly (Assembly Assembly, String [] Args) bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() bei System.Threading.ExecutionContext.Run (ExecutionContext ExecutionContext, Context Rückruf, Objektzustand) bei System.Threading.ThreadHelper.ThreadStart() Innerexception:
Ich weiß nicht, was ich tun soll, bitte helfen Sie mir!
Dank funktioniert es jetzt gut –