ImageDrawingVisual.cs
ImageDrawingVisual.csImageDrawingVisual类是一个基于WPF的自定义可视化元素用于高效显示图像using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Media;namespace ROIControl{public class ImageDrawingVisual:DrawingVisual{public ImageSource ImageSource{get{return(ImageSource)GetValue(ImageSourceProperty);}set{SetValue(ImageSourceProperty,value);}}publicstaticreadonly DependencyProperty ImageSourcePropertyDependencyProperty.Register(ImageSource,typeof(ImageSource),typeof(ImageDrawingVisual),newFrameworkPropertyMetadata(default(ImageSource),(d,e){ImageDrawingVisual controld as ImageDrawingVisual;if(controlnull)return;if(e.OldValue is ImageSource o){}if(e.NewValue is ImageSource n){}control.Draw();}));publicvoidDraw(){if(this.ImageSourcenull)return;using var dcthis.RenderOpen();var rectnewRect(0,0,this.ImageSource.Width,this.ImageSource.Height);dc.DrawImage(this.ImageSource,rect);}}}