This is a migrated thread and some comments may be shown as answers.

How to overwrite save command

4 Answers 141 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Somnath
Top achievements
Rank 1
Somnath asked on 06 Aug 2013, 03:13 PM
Hi,

I am using ImageEditor from the example, I want to get the final edited image in a stream or writable bitmap format, I don't want to save the image in the picture hub.

How do I archive that.

4 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 08 Aug 2013, 07:50 AM
Hello Somnath,

Thank you for your question.

Here's how you can get the final edited image in the Execute method of your command:

RadImageEditor currentEditor = (Application.Current as Application).RootVisual.FindChildByType<RadImageEditor>();
if (currentEditor.CurrentTool != null)
{
    return;
}
 
WriteableBitmap wb = (WriteableBitmap)currentEditor.ModifiedImage;

First we check if the CurrentEditor is null. This is necessary because when it is not null, it means that the command is executed in order to apply modifications from a single tool and when it is null then it is time for it to be saved. The command will allow you to execute your custom logic, in order to skip the default saving logic, you also need to use the cancelable event ImageSaving and set e.Cancel to true.

Let me know if you need further assistance here.
 
Regards,
Todor
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Somnath
Top achievements
Rank 1
answered on 08 Aug 2013, 09:05 AM
Thank you very much,
But I am not able to make it run, my be cause I have not writtten the code properly. I saw few example to overwrite the save button using custom class MySaveCommad.cs where it inherit ImageEditorCommandBase. But for Windows Phone i don't see the base class ImageEditorCommandBase.

Could you please write some more code that I should add in the xaml and in my cs file. I don't want to save the edited image rather I want to get the image data in WritableBitmap for further process.


Thanks
Somnath
0
Accepted
Deyan
Telerik team
answered on 13 Aug 2013, 07:27 AM
Hello Somnath,

Thanks for writing back.

You can simply handle the ImageSaving event, cancel the default saving routine and obtain the edited image as a writeable bitmap as shown below:

void imageEditor_ImageSaving(object sender, ImageSavingEventArgs e)
{
    e.Cancel = true;
 
    WriteableBitmap bitmap = this.imageEditor.ModifiedImage as WriteableBitmap;
}

Hope this helps.

Regards,
Deyan
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Somnath
Top achievements
Rank 1
answered on 13 Aug 2013, 12:33 PM
Thanks. This is exactly what I was looking for . Perfect.
Tags
ImageEditor
Asked by
Somnath
Top achievements
Rank 1
Answers by
Todor
Telerik team
Somnath
Top achievements
Rank 1
Deyan
Telerik team
Share this question
or