参考:

/// <summary>
/// 把内存里的BitmapImage数据保存到硬盘中
/// </summary>
/// <param name="bitmapImage">BitmapImage数据</param>
/// <param name="filePath">输出的文件路径</param>
public static void SaveBitmapImageIntoFile(BitmapImage bitmapImage, string filePath)
{
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmapImage)); using (var fileStream = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
{
encoder.Save(fileStream);
}
}
05-11 11:21