title: Divide 2d array into 8x8 blocks c#
body: <p>I have been surfing around the network, but couldn't find any good answer.
  So I have this code, that should crop my image(it's always 512x512) into 4096 8x8 blocks.So far so good.</p>
  
  <pre><code>private List&lt;int[,]&gt; PictureDivide(Bitmap Image0)
  {
      int[,] PartPic;
      List&lt;int[,]&gt; MacroBlocks = new List&lt;int[,]&gt;();
      HeightDivisions = Image0.Height / 8;
      WidthDivisions = Image0.Width / 8;           
      for (int a = 0; a &lt; Image0.Height; a = a + 8)
      {
          for (int b = 0; b &lt; Image0.Width; b = b + 8)
          {
              PartPic = new int[8, 8];
              for (int x = b, sx = 0; x &lt; (b + 8); x++, sx++)
              {
                  for (int y = a, sy = 0; y &lt; (a + 8); y++, sy++)
                  {
                      PartPic[sx, sy] = Image0.GetPixel(x, y).R;
                  }
  
              }
              MacroBlocks.Add(PartPic);
          }
      }            
      return MacroBlocks;
  }
  </code></pre>
  
  <p>But when I just redraw this image with no changes is broken, like I missed some pixels. Is something wrong with my code, or if you guys have any better soulution i'd be grateful for a tip.</p>
  
  <p>EDIT: Added example: Before-After. Maybe in how I reconstruct the image is doing something horribly wrong?</p>
  
  <p><a href="https://i.stack.imgur.com/VVdja.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VVdja.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/n5EFq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n5EFq.png" alt="enter image description here"></a></p>