WPF中怎么将多张图片合并成一张图片?
本帖最后由 lordboy 于 2013-05-14 11:20:51 编辑
RT...图片拼接...
------解决方案-------------------- /// <summary>
/// 将控件保存为图片
/// </summary>
/// <param name="control"></param>
/// <returns></returns>
static Stream GetImageFromControl(Control control)
{
MemoryStream ms = null;
DrawingVisual drawingVisual = new DrawingVisual();
using (DrawingContext context = drawingVisual.RenderOpen())
{
VisualBrush brush = new VisualBrush(control) { Stretch = Stretch.None };
context.DrawRectangle(brush, null, new Rect(0, 0, control.Width, control.Height));
context.Close();
}
RenderTargetBitmap bitmap = new RenderTargetBitmap((int)control.Width, (int)control.Height, 96, 96, PixelFormats.Pbgra32);
bitmap.Render(drawingVisual);
PngBitmapEncoder encode = new PngBitmapEncoder();
encode.Frames.Add(BitmapFrame.Create(bitmap));
ms = new MemoryStream();
encode.Save(ms);
return ms;
}
自己研究下.这里的control参数 是wpf的任何control,context相当与gdi+的graphic
------解决方案--------------------跟WPF关系不大。。。给你个链接你可以参考下。
http://www.smallqiao.com/124147.html