本文介绍了从图像控件将图像保存到特定路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友, 我想将图像保存到Image Control的特定路径.示例代码如下. XMLA代码 ----------
Dear Freinds, I want to save Image to particular path from Image Control. Sample coding are below. XMLA Code ----------
<Image Source="{Binding signat}" Canvas.Left="6" Canvas.Top="74" Height="423" x:Name="img_signature" Stretch="Fill" Width="573"> </Image>CS代码 -------
Cs code -------
Binding b = new Binding(); b.Source = ds.Tables["tab_grdbindload"]; b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; b.Path = new PropertyPath("signat"); this.img_signature.SetBinding(Image.SourceProperty, b);上面的编码用于从数据库加载图像. 现在,我想在特定路径中保存加载的图像. 预先感谢, Maha S.
The above coding used to loaded image from database. Now I want to save loaded image in particular path. Thanks in advance, Maha S.
推荐答案我的解决方案在这里工作正常.. my solution is here its working fine.. var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create((BitmapSource)img_signature.Source)); using (FileStream stream = new FileStream(strpath + strfilename, FileMode.Create)) encoder.Save(stream);
更多推荐
从图像控件将图像保存到特定路径
发布评论