title: How to convert BitmapFrame into BitmapImage
body: <p>My program uses some WPF APIs to process images in a folder.  I need to parse EXIF data from the images if there is any in order to get the value of the <code>DateTimeOriginal</code> property.  I've been using a <code>BitmapImage</code> to load the image from a <code>MemoryStream</code>, but I need a <code>BitmapFrame</code> object to get at the <code>BitmapMetadata</code> object.</p>
  
  <p>Here's my original code before I was given the requirement to get the <code>DateTimeOriginal</code> EXIF property:</p>
  
  <pre><code>BitmapImage src = new BitmapImage();
  try {
      using ( MemoryStream memoryStream = new MemoryStream( snapshot.ImageData ) ) {
          src.BeginInit();
          src.CacheOption  = BitmapCacheOption.OnLoad;
          src.StreamSource = memoryStream;
          src.EndInit();
      }
  } catch ( NotSupportedException ex ) {
      . . .
  }
  </code></pre>
  
  <p>Now, to get the <code>BitmapFrame</code>, I need to create a <code>BitmapDecoder</code> and use the <code>Frames[0]</code> property.  So I added the following right after the <code>using</code> statement:</p>
  
  <pre><code>BitmapDecoder decoder = BitmapDecoder.Create( memoryStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad );
  </code></pre>
  
  <p>This decodes the bitmap and gets the first Frame, which is cool.  I still need to create the <code>BitmapImage</code>.  I can do that by resetting the <code>MemoryStream's</code> position back to the beginning and keeping the code that's already there, but this will decode the same image a second time.</p>
  
  <p>Is there a way I can convert the <code>BitmapFrame</code> into a <code>BitmapImage</code>?  I thought I would cast the <code>BitmapFrame</code> into a <code>BitmapSource</code>object and then set the <code>BitmapImage's Source</code> propert, but the <code>BitmapImage</code> class doesn't seem to have a <code>Source</code> property.</p>
  
  <p>Is this possible?  If so, how is it done?</p>