- 博客(0)
- 资源 (2)
空空如也
wpf 简单的截图代码
图片截取和保存
private BitmapSource CreateElementScreenshot(Visual visual, int width, int height)
{
RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Default);
bmp.Render(visual);
return bmp;
}
private VisualBrush SaveImageSource(double width, double height, double x, double y)
{
Image img = new Image();
img.Source = CreateElementScreenshot(parentCanvas, Convert.ToInt32(Wwidth), Convert.ToInt32(Wheight));
img.Width = Wwidth;
img.Height = Wheight;
//img.Stretch = Stretch.Fill;
Rect r1 = new Rect(x, y, width, height);
img.Clip = new RectangleGeometry(r1);
VisualBrush vb = new VisualBrush(img);
return vb;
}
2012-03-19
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人