Question : convert bitmap to imagesource
Answered by : ho-van-chuong
public BitmapSource ConvertToBitmapSource(Bitmap src, ImageFormat imageFormat) { try { MemoryStream ms = new MemoryStream(); src.Save(ms, imageFormat); BitmapImage image = new BitmapImage(); image.BeginInit(); ms.Seek(0, SeekOrigin.Begin); image.StreamSource = ms; image.EndInit(); return image; } catch { // ignored } return null; }
Source : | Last Update : Fri, 04 Feb 22