Creates or updates a LEADTOOLS image region using the specified GDI+ region data.
public static void AddGdiPlusDataToRegion(RasterImage image,RasterRegionXForm xform,RegionData data,RasterRegionCombineMode combineMode)
Public Shared Sub AddGdiPlusDataToRegion( _ByVal image As Leadtools.RasterImage, _ByVal xform As Leadtools.RasterRegionXForm, _ByVal data As RegionData, _ByVal combineMode As Leadtools.RasterRegionCombineMode _)
public:static void AddGdiPlusDataToRegion(Leadtools.RasterImage^ image,Leadtools.RasterRegionXForm^ xform,RegionData^ data,Leadtools.RasterRegionCombineMode combineMode)
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) for this parameter, the scalar fields default to 1, the offsets default to 0, and the view perspective defaults to the image view perspective.
data
A System.Drawing.Drawing2D.RegionData object that defines the region to add.
combineMode
The action to take regarding the existing image region, if one is defined.
To update an existing region, specify how the new region is to be combined with the existing one using the combineMode parameter. For more information, refer to Leadtools.RasterRegionCombineMode.
This method can be used to copy the region data from one RasterImage to another, using the GetGdiPlusRegionData method.
To get the region data as Windows API HRGN data, use GetGdiRegionData and AddGdiDataToRegion.
To get the region data as platform independent byte array, use RasterRegion.GetData and RasterRegion.SetData.
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+.
This example will use AddGdiPlusDataToRegion and GetGdiPlusRegionData to add an elliptical region to a Leadtools.RasterImage, gets the region as a GDI+ RegionData object then re-sets it in another image.
using Leadtools;using Leadtools.Codecs;using Leadtools.Drawing;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;public void GdiPlusRegionDataExample(){RasterCodecs codecs = new RasterCodecs();string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_GdiPlusData.bmp");RegionData gdipRegionData = null;// Load the source imageusing (RasterImage image = codecs.Load(srcFileName)){// Add a polygon region to it// Add a polygon region to the imageint x1 = image.ImageWidth / 4;int y1 = image.ImageHeight / 4;int x2 = image.ImageWidth / 3;int y2 = image.ImageHeight / 3;LeadPoint[] pts ={new LeadPoint(x1, y1),new LeadPoint(x2, y1),new LeadPoint(x1, y2),new LeadPoint(x2, y2)};image.AddPolygonToRegion(null, pts, LeadFillMode.Winding, RasterRegionCombineMode.Set);// Save the region as a GDI+ RegionData objectgdipRegionData = RasterRegionConverter.GetGdiPlusRegionData(image, null);}// Re-load the source imageusing (RasterImage image = codecs.Load(srcFileName)){// Add the GDI+ region data we saved to itRasterRegionConverter.AddGdiPlusDataToRegion(image, null, gdipRegionData, RasterRegionCombineMode.Set);// Fill this region with YellowFillCommand cmd = new FillCommand(RasterColor.FromKnownColor(RasterKnownColor.Yellow));cmd.Run(image);// Save this imagecodecs.Save(image, destFileName, RasterImageFormat.Bmp, 24);}codecs.Dispose();}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.DrawingImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorPublic Sub GdiPlusRegionDataExample()Dim codecs As New RasterCodecs()Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"Dim destFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1_GdiPlusData.bmp"Dim gdipRegionData As RegionData = Nothing' Load the source imageUsing image As RasterImage = codecs.Load(srcFileName)' Add a polygon region to it' Add a polygon region to the imageDim x1 As Integer = image.ImageWidth \ 4Dim y1 As Integer = image.ImageHeight \ 4Dim x2 As Integer = image.ImageWidth \ 3Dim y2 As Integer = image.ImageHeight \ 3Dim pts() As LeadPoint ={New LeadPoint(x1, y1),New LeadPoint(x2, y1),New LeadPoint(x1, y2),New LeadPoint(x2, y2)}image.AddPolygonToRegion(Nothing, pts, LeadFillMode.Winding, RasterRegionCombineMode.Set)' Save the region as a GDI+ RegionData objectgdipRegionData = RasterRegionConverter.GetGdiPlusRegionData(image, Nothing)End Using' Re-load the source imageUsing image As RasterImage = codecs.Load(srcFileName)' Add the GDI+ region data we saved to itRasterRegionConverter.AddGdiPlusDataToRegion(image, Nothing, gdipRegionData, RasterRegionCombineMode.Set)' Fill this region with YellowDim cmd As New FillCommand(RasterColor.FromKnownColor(RasterKnownColor.Yellow))cmd.Run(image)' Save this imagecodecs.Save(image, destFileName, RasterImageFormat.Bmp, 24)End Usingcodecs.Dispose()End Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
