title: How can I read image pixels' values as RGB into 2d array?
body: <p>I was making a 2d map editor for my square tile platformer game, when I realized I could really use an image editor with its abilities to repaint adjacent pixels and many more, so I figured I should try and read a painted level by an app that will then convert it into a lightweigh format.</p>
  <p>I'm not sure if using a bitmap format is mandatory for such thing, but I guess, reading a specific pixel would be easier than with PNG for example.</p>
  <p>So my goal is to open an image, iterate through every pixel, look for those which colors fit my tile scheme and put corresponding tile into the array of blocks.</p>
  <p><em>Note: I already have my lightweigh format, so I need only reading pixels values into array.</em></p>
  <hr/>
  **Solution:** My sketch looks like this:
  <pre><code>var myBitmap = new Bitmap(@&quot;input.png&quot;);  
  
  for (int x = 0; x &lt; myBitmap.Width; x++)
      for (int y = 0; y &lt; myBitmap.Height; y++)
      {                    
          Color pixelColor = myBitmap.GetPixel(x, y);
          // things we do with pixelColor
      }
  </code></pre>
  <hr/>
  Example 2:
  <pre><code>var myBitmap = new Bitmap(@&quot;input.png&quot;);
  
  for (int x = 0; x &lt; myBitmap.Width; x++)
  {
      for (int y = 0; y &lt; myBitmap.Height; y++)
      {
          // Get the color of a pixel within myBitmap.
          Color pixelColor = myBitmap.GetPixel(x, y);
          string pixelColorStringValue =
              pixelColor.R.ToString(&quot;D3&quot;) + &quot; &quot; +
              pixelColor.G.ToString(&quot;D3&quot;) + &quot; &quot; +
              pixelColor.B.ToString(&quot;D3&quot;) + &quot;, &quot;;
  
          switch (pixelColorStringValue)
          {
              case &quot;255 255 255&quot;:
                  {
                      // white pixel
                      break;
                  }
              case &quot;000 000 000&quot;:
                  {
                      // black pixel
                      break;
                  }
          }
      }
  }
  </code></pre>