public static void Set(this ImageBoxViewModel vm, BitmapImage image, string name) { Application.Current.Dispatcher.Invoke(delegate { vm.Image = image; vm.Name = name; }); if (Properties.Settings.Default.AutoSaveImage) { vm.Save(true); } }
public static void Set(this ImageBoxViewModel vm, SKImage image, string name) { using var encoded = image.Encode(); using var stream = encoded.AsStream(); BitmapImage photo = new BitmapImage(); photo.BeginInit(); photo.CacheOption = BitmapCacheOption.OnLoad; photo.StreamSource = stream; photo.EndInit(); photo.Freeze(); Application.Current.Dispatcher.Invoke(delegate { vm.Image = photo; vm.Name = name; }); if (Properties.Settings.Default.AutoSaveImage) { vm.Save(true); } }