using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.IO; using System.Windows.Ink; namespace WpfApplication6 { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { DrawingAttributes drawingAttributes; public MainWindow() { InitializeComponent(); //创建 DrawingAttributes 类的一个实例 drawingAttributes = new DrawingAttributes(); //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的东西的引用 //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各类设置,,该属性的类型为 DrawingAttributes 型 inkCanvas.DefaultDrawingAttributes = drawingAttributes; //设置 DrawingAttributes 的 Color 属性设置颜色 drawingAttributes.Color = Colors.Red; } private void button1_Click(object sender, RoutedEventArgs e) { RenderTargetBitmap rtb = new RenderTargetBitmap(96, 96, this.Screen.Width, this.Screen.Height, PixelFormats.Default); rtb.Render(this.inkCanvas); BmpBitmapEncoder encoder = new BmpBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(rtb)); string file = "d:\\xxx.jpg"; using (Stream stm = File.Create(file)) { encoder.Save(stm); } } } }
相关文章
- using 释放资源
- SOLID architecture principles using simple C# examples
- Display LOV (List Of Values) Using Show_Lov In Oracle Forms
- Access denied for user 'root'@'localhost' (using password:YES)
- 在python中WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
- PostgreSQL Q&A: Building an Enterprise-Grade PostgreSQL Setup Using Open Source Tools
- IDEA报错“Access denied for user ‘root‘@‘localhost‘ (using password: YES)”
- 无法启动Tomcat,一闪而过。localhost:8080找不到网页。控制台输出Using CATALINA_BASE
- 启动Tomcat11出现Using CATALINA_BASE
- Getting Started with Entity Framework 6 Code First using MVC 5--Contoso 大学