LEADTOOLS WPF and Silverlight (Leadtools.Windows.Media assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.30
AddGeometryToRegion Method
See Also 
Leadtools.Windows.Media Namespace > RasterRegionConverter Class : AddGeometryToRegion Method



image
The source image.
xform
Leadtools.RasterRegionXForm object that LEADTOOLS uses to translate between display coordinates and image coordinates. If you specify null (Nothing in Visual Basic) in this parameter, the scalar fields default to 1, the offsets default to 0, and the view perspective defaults to the image view perspective.
geometry
The WPF/Silverlight geometry to add.
combineMode
The action to take regarding the existing image region, if one is defined.
image
The source image.
xform
Leadtools.RasterRegionXForm object that LEADTOOLS uses to translate between display coordinates and image coordinates. If you specify null (Nothing in Visual Basic) in this parameter, the scalar fields default to 1, the offsets default to 0, and the view perspective defaults to the image view perspective.
geometry
The WPF/Silverlight geometry to add.
combineMode
The action to take regarding the existing image region, if one is defined.
Creates or updates a LEADTOOLS image region by adding the specified WPF/Silverlight geometry.

Syntax

Visual Basic (Declaration) 
Public Shared Sub AddGeometryToRegion( _
   ByVal image As RasterImage, _
   ByVal xform As RasterRegionXForm, _
   ByVal geometry As Geometry, _
   ByVal combineMode As RasterRegionCombineMode _
) 
Visual Basic (Usage)Copy Code
Dim image As RasterImage
Dim xform As RasterRegionXForm
Dim geometry As Geometry
Dim combineMode As RasterRegionCombineMode
 
RasterRegionConverter.AddGeometryToRegion(image, xform, geometry, combineMode)
C# 
public static void AddGeometryToRegion( 
   RasterImage image,
   RasterRegionXForm xform,
   Geometry geometry,
   RasterRegionCombineMode combineMode
)
C++/CLI 
public:
static void AddGeometryToRegion( 
   RasterImage^ image,
   RasterRegionXForm^ xform,
   Geometry^ geometry,
   RasterRegionCombineMode combineMode
) 

Parameters

image
The source image.
xform
Leadtools.RasterRegionXForm object that LEADTOOLS uses to translate between display coordinates and image coordinates. If you specify null (Nothing in Visual Basic) in this parameter, the scalar fields default to 1, the offsets default to 0, and the view perspective defaults to the image view perspective.
geometry
The WPF/Silverlight geometry to add.
combineMode
The action to take regarding the existing image region, if one is defined.

Example

Visual BasicCopy Code
Public Sub AddGeometryToRegionExample()
      ' Load an image 
      Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")
      Dim dstFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_AddGeometryToRegion.jpg")

      Dim codecs As New RasterCodecs()

      Dim image As RasterImage = codecs.Load(srcFileName)

      ' We will add an ellipse region to the image

      ' Using WPF, create an elliptical geometry
      ' Create the ellipse geometry to add to the Path
      Dim ellipseGeometry As New EllipseGeometry()
      ellipseGeometry.Center = New Point(250, 250)
      ellipseGeometry.RadiusX = 200
      ellipseGeometry.RadiusY = 150

      Dim geometry As Geometry = ellipseGeometry

      ' Add this geometry to the image
      RasterRegionConverter.AddGeometryToRegion(image, Nothing, geometry, RasterRegionCombineMode.Set)

      ' Fill the image with a color
      Dim cmd As New FillCommand(RasterColor.FromKnownColor(RasterKnownColor.Red))
      cmd.Run(image)

      ' Save it
      codecs.Save(image, dstFileName, RasterImageFormat.Jpeg, 24)

      image.Dispose()

      codecs.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 AddGeometryToRegionExample()
   {
      // Load an image 
      string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
      string dstFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_AddGeometryToRegion.jpg");

      RasterCodecs codecs = new RasterCodecs();

      RasterImage image = codecs.Load(srcFileName);

      // We will add an ellipse region to the image

      // Using WPF, create an elliptical geometry
      // Create the ellipse geometry to add to the Path
      EllipseGeometry ellipseGeometry = new EllipseGeometry();
      ellipseGeometry.Center = new Point(250, 250);
      ellipseGeometry.RadiusX = 200;
      ellipseGeometry.RadiusY = 150;

      Geometry geometry = ellipseGeometry;

      // Add this geometry to the image
      RasterRegionConverter.AddGeometryToRegion(image, null, geometry, RasterRegionCombineMode.Set);

      // Fill the image with a color
      FillCommand cmd = new FillCommand(RasterColor.FromKnownColor(RasterKnownColor.Red));
      cmd.Run(image);

      // Save it
      codecs.Save(image, dstFileName, RasterImageFormat.Jpeg, 24);

      image.Dispose();

      codecs.Dispose();
   }

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

Remarks

To update an existing region, you specify how the new region is to be combined with the existing one using the combineMode parameter. For more information, refer to Leadtools.RasterRegionCombineMode.

For more information, refer to Creating a Region.

For more information, refer to Saving A Region.

For more information, refer to Working with the Existing Region.

For more information refer to RasterImage and WPF/Silverlight.

Requirements

Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also