C#/Winform
[C#] BitmapImage(ImageSource) to Image
kjun.kr
2022. 2. 18. 20:52
728x90
728x170
public static System.Drawing.Image Convert(System.Windows.Media.ImageSource image)
{
if (image == null) return null;
MemoryStream memoryStream = new MemoryStream();
System.Windows.Media.Imaging.BmpBitmapEncoder bmpBitmapEncoder = new System.Windows.Media.Imaging.BmpBitmapEncoder();
bmpBitmapEncoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create((System.Windows.Media.Imaging.BitmapSource)image));
encoder.Save(memoryStream);
return System.Drawing.Image.FromStream(memoryStream);
}
728x90
그리드형