我有一个XAML canvas元素,我需要将canvas元素及其中的任何内容保存为高质量的任何图像格式(JPEG,PNG),如何在Silverlight中使用c#做到这一点。我看到了Fjcore代码,但我不明白它正在执行操作,请提供代码说明并评论其操作。
You can try Imagetools for Silverlight library in Codeplex . Here is an example on saving a canvas element to JPEG image :
//Convert UIElement to Image
ei = ImageExtensions.ToImage(myCanvas);
//Save the image
SaveFileDialog saveDlg = new SaveFileDialog();
saveDlg.Filter = "JPEG Files (*.jpeg)|*.jpeg";
saveDlg.DefaultExt = ".jpeg";
if ((bool)saveDlg.ShowDialog())
{
using (Stream fs = saveDlg.OpenFile())
{
ei.WriteToStream(fs);
}
}
Further information on how to use it can be found in the link above, and as I see it, looked very simple.
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.