怎么使用Graphics 在ImageViewer上绘制线条?
1.我使用ImageViewerAddRegionInteractiveMode 绘制矩形,绘制后,想在此矩形的基础上绘制#形;
我使用如下代码无效:
currentGraphics = this.imageViewer.CreateGraphics();
Leadtools.LeadRect leadRect = this.imageViewer.Image.GetRegionBounds(null);
if (leadRect.Width == imageViewer.Image.Width && leadRect.Height == imageViewer.Image.Height) return;
currentGraphics.DrawLine(Pens.Red, new Point(leadRect.X != 0 ? 0 : leadRect.X, leadRect.Y), new Point(leadRect.X == imageViewer.Image.Width ? leadRect.X : imageViewer.Image.Width, leadRect.Y));
原来V18 在RasterImageViewer 的PostImagePaint可以通过Graphics绘制时可行的。
V19中尝试在PostRender事件中也不行:
if (this.imageViewer.Image != null)
{
Leadtools.LeadRect leadRect = this.imageViewer.Image.GetRegionBounds(null);
if (leadRect.Width == imageViewer.Image.Width && leadRect.Height == imageViewer.Image.Height)
{
return;
}
(e.Context as Graphics).DrawLine(Pens.Red, new Point(leadRect.X != 0 ? 0 : leadRect.X, leadRect.Y), new Point(leadRect.X == imageViewer.Image.Width ? leadRect.X : imageViewer.Image.Width, leadRect.Y));
//e.Graphics.DrawLine(Pens.Red, new Point(leadRect.X != 0 ? 0 : leadRect.X, leadRect.Y), new Point(leadRect.X == imageViewer.Image.Width ? leadRect.X : imageViewer.Image.Width, leadRect.Y));
}
2.我想切分A3为A4,需要在A3影像上显示一条线,并且可以移动线条,以便修改切割区域,如何绘制线条。
|
|