title: How to get an array System.Windows.Media.Color from a BitmapImage?
body: <p>I'm working on a project for edit icons and I need to load an icon.  I use the following code for save this icon:</p>
  
  <pre><code>        var sd = new SaveFileDialog();
          sd.ShowDialog();
          sd.Filter = "File *.ico|*.ico";
          sd.FilterIndex = 0;
          var path = sd.FileName;
          if (!sd.CheckPathExists) return;
  
          var w = new WriteableBitmap(Dimention, Dimention, 1, 1, PixelFormats.Pbgra32, null);
          var pix = new int[Dimention,Dimention];
          for (int i = 0; i &lt; Dimention; i++)
              for (int j = 0; j &lt; Dimention; j++)
                  pix[i, j] = ToArgb(IconCanvas.Board[i, j].Background.Color);
  
          w.WritePixels(new Int32Rect(0, 0, Dimention, Dimention), pix, Dimention*4, 0, 0);
          var e = new BmpBitmapEncoder();
          e.Frames.Add(BitmapFrame.Create(w));
          var file = new FileStream(path, FileMode.Create);
          e.Save(file);
          file.Close();
  </code></pre>
  
  <p>So, I need get an Color[,] from these images saved. I assume the icon's size is a square (width = height) . Thanks for your help.</p>