2023年7月21日
How do I save a BitmapImage from memory into a file in WPF C#?
How do I save a BitmapImage from memory into a file in WPF C#? – Stack Overflow
public static void Save(this BitmapImage image, string filePath)
{
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(image));
using (var fileStream = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
{
encoder.Save(fileStream);
}
}