title: FormatConvertedBitmap with alpha
body: <p>I've a problem in WPF. I'm making a delete button with an image in it. When the button is disabled, however, I wanted to display a greyscale image.</p>
  
  <p>I found the <a href="http://weblogs.asp.net/thomaslebrun/wpf-how-to-gray-the-icon-of-a-menuitem" rel="nofollow noreferrer">Thomas Lebrun implementation</a>, but I don't want to add the whole class in my program. Instead I tried to mimic the behavior in this way:</p>
  
  <pre><code>BitmapImage img_Delete = new System.Windows.Media.Imaging.BitmapImage(new Uri("the png URI", UriKind.RelativeOrAbsolute));
  ImageSource img_DeleteDisabled = null;
  
  [...]
  Button btDel = new Button() { Width = 20, Height = 20, ToolTip = "Delete", Margin = new Thickness(5), HorizontalAlignment = System.Windows.HorizontalAlignment.Right };
  btDel.IsEnabled = isdeletable(obj);
  
  if (!btDel.IsEnabled &amp;&amp; (img_DeleteDisabled == null))
  {
      img_DeleteDisabled = new FormatConvertedBitmap(img_Delete, PixelFormats.Gray32Float, null, 0);
  }
  
  btDel.Content = (new System.Windows.Controls.Image()
  {
      Width = 16,
      Height = 16,
      HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
      VerticalAlignment = System.Windows.VerticalAlignment.Stretch,
      Source = btDel.IsEnabled ? img_Delete : img_DeleteDisabled
  });
  </code></pre>
  
  <p>It behaves in the expected way, except.. Well, I'll show you:</p>
  
  <p><a href="https://i.stack.imgur.com/o3JXx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o3JXx.png" alt="Enabled and disabled"></a></p>
  
  <p>The left one is enabled, the right one is disabled</p>
  
  <p>As you can see the alpha channel is gone. How can I integrate it back?</p>