title: How to convert a PNG image to grayscale and without losing the transparency C#
body: <p>I want to convert a transparent png image to greyscale without losing its transparency.</p>
  
  <p>The problem is the algorithm that I am using in is converting the transparent part into Black, which some picture with black character wouldn't be shown. To give you an idea.</p>
  
  <p><strong>Heres the original picture :</strong></p>
  
  <p><a href="https://i.stack.imgur.com/VdSMd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VdSMd.png" alt="enter image description here"></a></p>
  
  <p><strong>Look what happens when I pass it through the algorithm.</strong></p>
  
  <p><a href="https://i.stack.imgur.com/m6Cvk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m6Cvk.png" alt="enter image description here"></a></p>
  
  <p>The algorithm :</p>
  
  <pre><code>       public static void ToWhiteBlack(Bitmap original)
      {
          try
          {
  
              for (var i = 0; i &lt; original.Width; i++)
              {
                  for (var j = 0; j &lt; original.Height; j++)
                  {
                      var originalColor = original.GetPixel(i, j);
                      var grayScale = (int) ((originalColor.R*0.3) + (originalColor.G*0.59) + (originalColor.B*0.11));
                      var corEmEscalaDeCinza = Color.FromArgb(grayScale, grayScale, grayScale);
                      original.SetPixel(i, j, corEmEscalaDeCinza);
                  }
              }
          }
          catch
          {
  
          }
  
      }
  </code></pre>