title: In WinRT How do I encode a png but keep it in memory as an in memory bmp instead of writing it to a file?
body: <p>The following code creates a bmp from a raw vector of bits and saves it to a file.
  Since I only really want to have the bitmap stored in memory and manipulate it from there (ie get values of a the colours at certain pixels), how would I go about modifying this code to just have the image in m emory so that other image processing libraries can access the bmp?</p>
  <p>Currently I save the image to a file, and then load that file back in using another library, but seems the file saving stage is a bit redundant?</p>
  <p>While this example is in rust, i'd be fine with c++ code too.</p>
  <pre><code>let path = std::env::current_dir()
      .unwrap()
      .to_string_lossy()
      .to_string();
  
    let folder = StorageFolder::GetFolderFromPathAsync(path.as_str())?.get()?;
  
    let file = folder
      .CreateFileAsync(&quot;screenshot.png&quot;, CreationCollisionOption::ReplaceExisting)?
      .get()?;
  
      let stream = file.OpenAsync(FileAccessMode::ReadWrite)?.get()?;
      let encoder = BitmapEncoder::CreateAsync(BitmapEncoder::BmpEncoderId()?, stream)?.get()?;
  
    encoder.SetPixelData(
      BitmapPixelFormat::Bgra8,
      BitmapAlphaMode::Premultiplied,
      (item_size.Width - 18) as u32,
      (item_size.Height - 18) as u32,
      1.0,
      1.0,
      &amp;bits,
    )?;
  
    Ok(())
  </code></pre>