←Select platform

ToBezierPoints Method

Summary
Converts the curve points to an array of Bézier points.
Syntax
C#
C++/CLI
Java
Python
public LeadPoint[] ToBezierPoints() 
public LeadPoint[] toBezierPoints(); 
public: 
array<LeadPoint>^ ToBezierPoints();  
def ToBezierPoints(self): 

Return Value

An array of LeadPoint values that contain the Bézier points.

Remarks

This method is used to convert a standard curve to an array of Bézier 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 Bézier points, using System.Drawing.Graphics.DrawBeziers to draw the equivalent Bezier(s).

Example

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

C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
 
 
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:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.16
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.