public static void AddRegionToRegion( RasterImage image, RasterRegionXForm xform, IntPtr region, RasterRegionCombineMode combineMode )
'Declaration Public Overloads Shared Sub AddRegionToRegion( _ ByVal image As RasterImage, _ ByVal xform As RasterRegionXForm, _ ByVal region As IntPtr, _ ByVal combineMode As RasterRegionCombineMode _ )
'Usage Dim image As RasterImage Dim xform As RasterRegionXForm Dim region As IntPtr Dim combineMode As RasterRegionCombineMode RasterRegionConverter.AddRegionToRegion(image, xform, region, combineMode)
public static void AddRegionToRegion( RasterImage image, RasterRegionXForm xform, IntPtr region, RasterRegionCombineMode combineMode )
function Leadtools.Drawing.RasterRegionConverter.AddRegionToRegion(RasterImage,RasterRegionXForm,IntPtr,RasterRegionCombineMode)( image , xform , region , combineMode )
public: static void AddRegionToRegion( RasterImage^ image, RasterRegionXForm^ xform, IntPtr region, RasterRegionCombineMode combineMode )
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 GDI/GDI+.
Public Sub AddRegionToRegionGdi_Example() Dim codecs As New RasterCodecs() Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp" Dim destFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1_AddRegionToRegion.bmp" ' Load the image Dim image As RasterImage = codecs.Load(srcFileName) ' Create a GDI+ region Dim region As Region Using path As New GraphicsPath() path.AddRectangle(New Rectangle(100, 100, 200, 200)) path.AddEllipse(New Rectangle(150, 150, 200, 200)) region = New Region(path) End Using ' Get the Windows GDI handle for this region Dim hrgn As IntPtr Using btmp As New Bitmap(1, 1) Using graphics As Graphics = graphics.FromImage(btmp) hrgn = region.GetHrgn(graphics) End Using End Using ' Add this region to the raster image RasterRegionConverter.AddRegionToRegion(image, Nothing, hrgn, RasterRegionCombineMode.Set) region.ReleaseHrgn(hrgn) region.Dispose() ' Draw something on the image Dim command As New InvertCommand() command.Run(image) ' Save the image codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24) image.Dispose() codecs.Dispose() End Sub
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:\Users\Public\Documents\LEADTOOLS Images"; }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2