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



Defines a curve.

Object Model

RasterCurve Class

Syntax

Visual Basic (Declaration) 
Public Class RasterCurve 
Visual Basic (Usage)Copy Code
Dim instance As RasterCurve
C# 
public class RasterCurve 
C++/CLI 
public ref class RasterCurve 

Example

This sample creates a smooth region that goes through five points, and inverts the region.

Visual BasicCopy Code
Public Sub RasterCurveExample()
      Dim codecs As RasterCodecs = New RasterCodecs()

      ' load an image
      Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")
      Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_curveinverted.bmp")
      Dim image As RasterImage = codecs.Load(srcFileName)

      ' create a new curve object
      Dim curve As RasterCurve = New RasterCurve()

      ' define the the curve
      curve.Points.Add(New LeadPoint(30, 30))
      curve.Points.Add(New LeadPoint(30, 200))
      curve.Points.Add(New LeadPoint(130, 130))
      curve.Points.Add(New LeadPoint(75, 75))
      curve.Points.Add(New LeadPoint(130, 30))

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

      image.AddCurveToRegion(Nothing, curve, RasterRegionCombineMode.Set)

      ' do something with the region
      Dim cmd As InvertCommand = New InvertCommand()
      cmd.Run(image)

      ' save the image back to disk
      codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24)

      ' Cleanup
      image.Dispose()
   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 RasterCurveExample()
   {
      RasterCodecs codecs = new RasterCodecs();

      // load an image
      string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
      string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_curveinverted.bmp");
      RasterImage image = codecs.Load(srcFileName);

      // create a new curve object
      RasterCurve curve = new RasterCurve();

      // define the the curve
      curve.Points.Add(new LeadPoint(30, 30));
      curve.Points.Add(new LeadPoint(30, 200));
      curve.Points.Add(new LeadPoint(130, 130));
      curve.Points.Add(new LeadPoint(75, 75));
      curve.Points.Add(new LeadPoint(130, 30));

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

      image.AddCurveToRegion(null, curve, RasterRegionCombineMode.Set);

      // do something with the region
      InvertCommand cmd = new InvertCommand();
      cmd.Run(image);

      // save the image back to disk
      codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24);

      // Cleanup
      image.Dispose();
   }

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

Remarks

The RasterCurve class defines the curve to be used with the RasterImage.AddCurveToRegion method to draw a curve using an array of LeadPoint objects. The ToBezierPoints method is used to convert a curve to a Bezier. The RasterCurve class can define two types of curves, RasterCurveType.Standard and RasterCurveType.Bezier.

Inheritance Hierarchy

System.Object
   Leadtools.RasterCurve

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