←Select platform

AddRegionToRegion(RasterImage,RasterRegionXForm,IntPtr,RasterRegionCombineMode) Method

Summary
Creates or updates a LEADTOOLS image region by adding the specified Windows region handle.
Syntax
C#
C++/CLI
Python
public static void AddRegionToRegion( 
   RasterImage image, 
   RasterRegionXForm xform, 
   IntPtr region, 
   RasterRegionCombineMode combineMode 
) 
public: 
static void AddRegionToRegion(  
   RasterImage^ image, 
   RasterRegionXForm^ xform, 
   IntPtr region, 
   RasterRegionCombineMode combineMode 
)  
def AddRegionToRegion(self,image,xform,region,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 VB) in this parameter, the scalar fields default to 1, the offsets default to 0, and the view perspective defaults to the image view perspective.

region
The Windows region handle to add.

combineMode
The action to take regarding the existing image region, if one is defined.

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 the following:

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
 
 
public void AddRegionToRegionGdi_Example() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
   string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_AddRegionToRegion.bmp"); 
 
   // Load the image 
   RasterImage image = codecs.Load(srcFileName); 
 
   // Create a GDI+ region 
   Region region; 
 
   using (GraphicsPath path = new GraphicsPath()) 
   { 
      path.AddRectangle(new Rectangle(100, 100, 200, 200)); 
      path.AddEllipse(new Rectangle(150, 150, 200, 200)); 
      region = new Region(path); 
   } 
 
   // Get the Windows GDI handle for this region 
   IntPtr hrgn; 
 
   using (Bitmap btmp = new Bitmap(1, 1)) 
   { 
      using (Graphics graphics = Graphics.FromImage(btmp)) 
      { 
         hrgn = region.GetHrgn(graphics); 
      } 
   } 
 
   // Add this region to the raster image 
   RasterRegionConverter.AddRegionToRegion(image, null, hrgn, RasterRegionCombineMode.Set); 
 
   region.ReleaseHrgn(hrgn); 
   region.Dispose(); 
 
   // Draw something on the image 
   InvertCommand command = new InvertCommand(); 
   command.Run(image); 
 
   // Save the image 
   codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24); 
 
   image.Dispose(); 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

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

Leadtools.Drawing Assembly

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