我在图片上拉框速度慢,代码如下:
private void imageViewer1_MouseDown(object sender, MouseEventArgs e)
{
x1 = Convert.ToInt32(e.X / myimageviewer.ScaleFactor);
y1 = Convert.ToInt32(e.Y / myimageviewer.ScaleFactor);
imageViewer1.Image.AddRectangleToRegion(null, new LeadRect(0, 0, 0, 0), RasterRegionCombineMode.Set);
}
private void imageViewer1_MouseMove(object sender, MouseEventArgs e)
{
x2 = Convert.ToInt32(e.X / imageViewer1.ScaleFactor);
y2 = Convert.ToInt32(e.Y / imageViewer1.ScaleFactor);
myrect.X = Math.Min(x1, x2); myrect.Y = Math.Min(y1, y2);
myrect.Width = Math.Abs(x2 - x1); myrect.Height = Math.Abs(y2 - y1);
imageViewer1.Image.AddRectangleToRegion(null, myrect, RasterRegionCombineMode.Set);
}
请问如何提高速度,在MouseMove时画出黑色虚拟框,MouseUP时才执行imageViewer1.Image.AddRectangleToRegion(null, myrect, RasterRegionCombineMode.Set);画出真实框。
谢谢,不胜感激。
|
|