在WinRT上保存带有背景图像的画布 [英] Save canvas with background image on WinRT
本文介绍了在WinRT上保存带有背景图像的画布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为C#for WinRT的儿童制作一个简单的绘图应用程序。用户可以选择一张图片并画一点。但是如何保存图像(与背景一起)?
I want to make a simple drawing app for children with C# for WinRT. The user can choose a picture and draw a little bit. But how can I save the image (together with the background)? There is no functionality to save the image with background.
推荐答案
我试图使用您的库将Canvas渲染为图像文件但我得到这个错误运行时:找不到组件(从HRESULT:0x88982F50异常)。代码如下:
I tried to use your library to render a Canvas into an image file but I got this error runtime: "Can't find component. (Exception from HRESULT: 0x88982F50)". Code looks like this:
//SAVE
private async void saveButton_Click(object sender, RoutedEventArgs e)
{
await SaveToFile();
}
public async Task SaveToFile()
{
var wb = new WriteableBitmap(1, 1);
await wb.Render(canvas);
Windows.Storage.Pickers.FileSavePicker save = new Windows.Storage.Pickers.FileSavePicker();
save.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
save.DefaultFileExtension = ".jpg";
save.FileTypeChoices.Add("JPG", new string[] { ".jpg" });
StorageFile filesave = await save.PickSaveFileAsync();
await wb.SaveToFile(filesave, Guid.NewGuid());
}
这篇关于在WinRT上保存带有背景图像的画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文