fork download
  1. private void OutputColor(Bitmap bm)
  2. {
  3. r = new Rectangle(1150, 410, 320, 316);
  4.  
  5. bd = bm.LockBits(r, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
  6.  
  7. // Get address of first line
  8. IntPtr ptr = bd.Scan0;
  9.  
  10. int bytes = Math.Abs(bd.Stride) * bm.Height;
  11. byte[] rgbValues = new byte[bytes];
  12.  
  13. // Copy the RGB values into the array
  14. Marshal.Copy(ptr, rgbValues, 0, bytes);
  15.  
  16. // Calculate average and set it.
  17. for (int y = r.Y; y < r.Y + r.Height; y += 38)
  18. {
  19. for (int x = r.X; x < r.X + r.Width; x += 40)
  20. {
  21. SetAverageColor(ref rgbValues, x, y);
  22. }
  23. }
  24.  
  25. // Copy the RGB values back to the bitmap
  26. Marshal.Copy(rgbValues, 0, ptr, bytes);
  27.  
  28. bm.UnlockBits(bd);
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
System.AccessViolationException was unhandled
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=mscorlib
  StackTrace:
       at System.Runtime.InteropServices.Marshal.CopyToManaged(IntPtr source, Object destination, Int32 startIndex, Int32 length)
       at System.Runtime.InteropServices.Marshal.Copy(IntPtr source, Byte[] destination, Int32 startIndex, Int32 length)
       at BlitzBot.BoardScraper.OutputColor(Bitmap bm) in C:\Users\zol\Documents\Visual Studio 2010\Projects\C#\BlitzBot\BlitzBot\BoardScraper.cs:line 69
       at BlitzBot.BoardScraper.InitializeBitmap() in C:\Users\zol\Documents\Visual Studio 2010\Projects\C#\BlitzBot\BlitzBot\BoardScraper.cs:line 39
       at BlitzBot.BoardScraper..ctor() in C:\Users\zol\Documents\Visual Studio 2010\Projects\C#\BlitzBot\BlitzBot\BoardScraper.cs:line 24
       at BlitzBot.MainForm..ctor() in C:\Users\zol\Documents\Visual Studio 2010\Projects\C#\BlitzBot\BlitzBot\MainForm.cs:line 20
       at BlitzBot.Program.Main() in C:\Users\zol\Documents\Visual Studio 2010\Projects\C#\BlitzBot\BlitzBot\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
compilation info
prog.cs(1,14): error CS0116: A namespace can only contain types and namespace declarations
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty