I've been looking for a way to save a Canvas' (Windows.UI.Xaml.Controls) DataContext as an image or get it as a stream. I'm currently using it for drawing on an image and want to save the image with the drawn lines. Maybe I'm doing it wrong, so please enlighten me! :-)
On UWP I would suggest to use the InkCanvas.
You can store the Strokes like this:
var savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
savePicker.FileTypeChoices.Add("Gif with embedded ISF", new
System.Collections.Generic.List<string> { ".gif" });
StorageFile file = await savePicker.PickSaveFileAsync();
if (null != file)
{
try
{
using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
await myInkCanvas.InkPresenter.StrokeContainer.SaveAsync(stream);
}
}
catch (Exception ex)
{
GenerateErrorMessage();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.