标签:io ar for sp on c new ad window
/// <summary>
/// 功能:将Canvas画布内容保存为jpg格式图片
/// 作者:GYS | 日期:2013年9月9日
/// </summary>
/// <param name="filePath"></param>
/// <param name="pixBox"></param>
private void SaveAsJpeg(string filePath, Canvas pixBox)
{
try
{
RenderTargetBitmap bmp = new RenderTargetBitmap((int)picBox.Width, (int)picBox.Height, 96, 96, PixelFormats.Pbgra32);
bmp.Render(pixBox);
string Extension = System.IO.Path.GetExtension(filePath).ToLower();
BitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmp));
using (Stream stm = File.Create(filePath))
{
encoder.Save(stm);
}
}
catch
{
System.Windows.Forms.MessageBox.Show("图片保存失败");
}
}
标签:io ar for sp on c new ad window
原文地址:http://www.cnblogs.com/qust/p/3954713.html