InkCanvas 保存图片

前端之家收集整理的这篇文章主要介绍了InkCanvas 保存图片前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_301_0@将 InkCanvas 里面的画面,保存为图片

@H_301_0@* 该方法,保存的图片没有黑色的边框

@H_301_0@private void ImageSave(InkCanvas inkCanvas,string _imageFile) { double width = inkCanvas.ActualWidth; double height = inkCanvas.ActualHeight; RenderTargetBitmap bmpCopied = new RenderTargetBitmap((int)Math.Round(width),(int)Math.Round(height),96,PixelFormats.Default); DrawingVisual dv = new DrawingVisual(); using (DrawingContext dc = dv.RenderOpen()) { VisualBrush vb = new VisualBrush(inkCanvas); dc.DrawRectangle(vb,null,new Rect(new System.Windows.Point(),new System.Windows.Size(width,height))); } bmpCopied.Render(dv); using (FileStream file = new FileStream(_imageFile,FileMode.Create,FileAccess.Write)) { BmpBitmapEncoder encoder = new BmpBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmpCopied)); encoder.Save(file); } }

原文链接:https://www.f2er.com/vb/259965.html

猜你在找的VB相关文章