Dear,
When an image that is being saved in the imageeditor, it has to be used in a following step.
First I invoke the Save() function on the imageeditor:
imageeditor.Save(filePath: newfilename);
Then, the ImageSaved() event is triggered with the following code
private void imageeditor_ImageSaved(object sender, ImageSavedEventArgs e)
{
var locationofeditedimage = e.Location;
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(locationofeditedimage);
myBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
myBitmapImage.DecodePixelWidth = 100;
myBitmapImage.EndInit();
ImageSource image = myBitmapImage;
}
However, it is somehow locked by the proces, giving the error
"The process cannot access the file 'xxxx' because it is being used by another process."
Do I need to reset the editor, or dispose somehow, so the file is being released?
Best regards,
Dear,
I have checked your sample project and that does work indeed. However, in my specific case it is still not working. I have created a repo with a small sample: KoenJanssensPD/SyncfusionImageEditorTest (github.com)
Could you please check?
Basically, when you select an image in the left list, you can make edits in the editor on the right. When hitting CTRL-S the edited file is being saved as [originalfilename]_edited.[originalextension] in the same folder. After saving, the thumbnail of the edited image should be shown next to the original file... However, now, when hitting CTRL-S, the file is saved but it fails to retrieve that image to generate the thumbnail for it...
Sorry for the delay. Currently, our development team is trying to find a workaround solution to overcome this problem by creating the edited image thumbnail using the stream from the ImageSaving event when saving the image. We will let you know the further details on February 15, 2022.
|
In EditableImage.cs
…
public BitmapImage EditedImage
{
get { return editedImage; }
set
{
editedImage = value;
OnPropertyChanged();
OnPropertyChanged(nameof(BitmapImageEditedThumbnail));
}
}
…
public BitmapImage BitmapImageEditedThumbnail => editedImage != null ? editedImage : !string.IsNullOrEmpty(editedFileLocation) ? GenerateBitmap(editedFileLocation, 100) : null;
… |
|
In EditableImagesView.xaml
…
<editor:SfImageEditor x:Name="ImageEditor"
Grid.Column="1"
ImageSource="{Binding ImageForEditor}"
ImageSaving="ImageEditor_ImageSaving"
ImageSaved="ImageEditor_ImageSaved">
</editor:SfImageEditor>
… |
|
In EditableImagesView.xaml.cs
…
private void ImageEditor_ImageSaved(object sender, Syncfusion.UI.Xaml.ImageEditor.ImageSavedEventArgs e)
{
//viewModel.SelectedImage.EditedFileLocation = e.Location;
}
private void ImageEditor_ImageSaving(object sender, ImageSavingEventArgs e)
{
e.Stream.Seek(0, 0);
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = e.Stream;
bitmapImage.DecodePixelWidth = 100;
bitmapImage.EndInit();
viewModel.SelectedImage.EditedImage = bitmapImage;
}
… |