title: Get file Thumbnail image with transparency
body: <p>I want to get file's thumbnail with transparency.<br/>
  I have the following code to achieve it:</p>
  
  <pre><code>BitmapImage GetThumbnail(string filePath)
  {
      ShellFile shellFile = ShellFile.FromFilePath(filePath);
      BitmapSource shellThumb = shellFile.Thumbnail.ExtraLargeBitmapSource;
  
      Bitmap bmp = new Bitmap(shellThumb.PixelWidth, shellThumb.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
      BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
      shellThumb.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
      bmp.UnlockBits(data);
  
      MemoryStream ms = new MemoryStream();
      bmp.Save(ms, ImageFormat.Png);
      ms.Position = 0;
      BitmapImage bi = new BitmapImage();
      bi.BeginInit();
      bi.StreamSource = ms;
      bi.CacheOption = BitmapCacheOption.None;
      bi.EndInit();
  
      return bi;
  }
  </code></pre>
  
  <p>I mixed the codes from here:<br/>
  <a href="https://stackoverflow.com/questions/2284353/is-there-a-good-way-to-convert-between-bitmapsource-and-bitmap">Is there a good way to convert between BitmapSource and Bitmap?</a><br/>
  and<br/>
  <a href="https://stackoverflow.com/questions/94456/load-a-wpf-bitmapimage-from-a-system-drawing-bitmap">Load a WPF BitmapImage from a System.Drawing.Bitmap</a></p>
  
  <p>With this way, I convert <code>BitmapSource</code> to Bitmap, then I covert the Bitmap to <code>BitmapImage</code>.
  I am pretty sure there's a way to covert <code>BitmapSource</code> directly to <code>BitmapImage</code> <strong>while saving the transparency</strong>.</p>