private void DrawDistortedLine(Graphics canvas, Pen pen, PointF a, PointF b, ProjectiveMapping projectiveMapping, DistortionHelper distorter, IImageToViewportTransformer transformer) { a = projectiveMapping.Forward(a); b = projectiveMapping.Forward(b); if (distorter != null && distorter.Initialized) { a = distorter.Distort(a); b = distorter.Distort(b); List <PointF> curve = distorter.DistortLine(a, b); List <Point> transformed = transformer.Transform(curve); canvas.DrawCurve(penEdges, transformed.ToArray()); } else { canvas.DrawLine(pen, transformer.Transform(a), transformer.Transform(b)); } }
private void DrawTickMark(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, TickMark tick, SolidBrush brushFill, SolidBrush fontBrush, Font font) { string label = String.Format("{0}", Math.Round(tick.Value, 3)); PointF location; if (distorter != null && distorter.Initialized) { location = distorter.Distort(tick.ImageLocation); } else { location = tick.ImageLocation; } PointF transformed = transformer.Transform(location); SizeF labelSize = canvas.MeasureString(label, font); PointF textPosition = GetTextPosition(transformed, tick.TextAlignment, labelSize); RectangleF backRectangle = new RectangleF(textPosition, labelSize); RoundedRectangle.Draw(canvas, backRectangle, brushFill, font.Height / 4, false, false, null); canvas.DrawString(label, font, fontBrush, backRectangle.Location); }
/// <summary> /// Returns the origin of the coordinate system in image coordinates. /// </summary> public PointF GetOrigin() { return(distortionHelper.Distort(calibrator.Untransform(PointF.Empty))); }