LEADTOOLS (Leadtools assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
ToBezierPoints Method
See Also 
Leadtools Namespace > RasterCurve Class : ToBezierPoints Method



Converts the curve points to an array of Bezier points.

Syntax

Visual Basic (Declaration) 
Public Function ToBezierPoints() As LeadPoint()
Visual Basic (Usage)Copy Code
Dim instance As RasterCurve
Dim value() As LeadPoint
 
value = instance.ToBezierPoints()
C# 
public LeadPoint[] ToBezierPoints()
C++/CLI 
public:
array<LeadPoint>^ ToBezierPoints(); 

Return Value

An array of LeadPoint values that contain the Bezier points.

Example

This sample draws a smooth closed curve on a graphics that goes through five points.

Visual BasicCopy Code
Public Sub ToBezierPointsExample()
      ' Define the curve
      Dim curve As RasterCurve = New RasterCurve()

      curve.Points.Add(New LeadPoint(130, 130))
      curve.Points.Add(New LeadPoint(130, 300))
      curve.Points.Add(New LeadPoint(230, 230))
      curve.Points.Add(New LeadPoint(175, 175))
      curve.Points.Add(New LeadPoint(230, 130))

      curve.Type = RasterCurveType.Standard
      curve.FillMode = LeadFillMode.Winding
      curve.Tension = 0.5
      curve.Close = RasterCurveClose.Close

      ' convert this curve into bezier points
      Dim bezierPoints As LeadPoint() = curve.ToBezierPoints()

      ' Draw this curve on a bitmap
      Using btmp As New System.Drawing.Bitmap(400, 400)
         Using g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(btmp)
            g.FillRectangle(System.Drawing.Brushes.White, New System.Drawing.Rectangle(0, 0, 400, 400))

            ' Convert the LeadPoint array to a Point array
            Dim pts(bezierPoints.Length - 1) As System.Drawing.Point
            For i As Integer = 0 To bezierPoints.Length - 1
               pts(i) = New System.Drawing.Point(bezierPoints(i).X, bezierPoints(i).Y)
            Next

            g.DrawBeziers(System.Drawing.Pens.Black, pts)
         End Using

         ' save this image to disk
         Dim fileName As String = Path.Combine(LEAD_VARS.ImagesDir, "ToBezierPoints.bmp")
         btmp.Save(fileName, System.Drawing.Imaging.ImageFormat.Bmp)

      End Using
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
public void ToBezierPointsExample()
   {
      // Define the curve
      RasterCurve curve = new RasterCurve();

      curve.Points.Add(new LeadPoint(130, 130));
      curve.Points.Add(new LeadPoint(130, 300));
      curve.Points.Add(new LeadPoint(230, 230));
      curve.Points.Add(new LeadPoint(175, 175));
      curve.Points.Add(new LeadPoint(230, 130));

      curve.Type = RasterCurveType.Standard;
      curve.FillMode = LeadFillMode.Winding;
      curve.Tension = 0.5;
      curve.Close = RasterCurveClose.Close;

      // convert this curve into bezier points
      LeadPoint[] bezierPoints = curve.ToBezierPoints();

      // Draw this curve on a bitmap
      using(System.Drawing.Bitmap btmp = new System.Drawing.Bitmap(400, 400))
      {
         using(System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(btmp))
         {
            g.FillRectangle(System.Drawing.Brushes.White, new System.Drawing.Rectangle(0, 0, 400, 400));

            // Convert the LeadPoint array to a Point array
            System.Drawing.Point[] pts = new System.Drawing.Point[bezierPoints.Length];
            for(int i = 0; i < bezierPoints.Length; i++)
            {
               pts[i] = new System.Drawing.Point(bezierPoints[i].X, bezierPoints[i].Y);
            }

            g.DrawBeziers(System.Drawing.Pens.Black, pts);
         }

         // save this image to disk
         string fileName = Path.Combine(LEAD_VARS.ImagesDir, "ToBezierPoints.bmp");
         btmp.Save(fileName, System.Drawing.Imaging.ImageFormat.Bmp);
      }
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
SilverlightCSharpCopy Code
SilverlightVBCopy Code

Remarks

This method is used to convert a standard curve to an array of Bezier control points. A standard curve (RasterCurveType.Standard) is defined by the current RasterCurve. The standard curve passes through all of the points in the Points collection, and is continuous at each point. This method can be used to draw a curve by converting it to an array of Bezier points, using System.Drawing.Graphics.DrawBeziers to draw the equivalent Bezier(s).

Requirements

Target Platforms: Silverlight, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only), Windows Phone 7

See Also