public static void AddGdiPlusDataToRegion( RasterImage image, RasterRegionXForm xform, RegionData data, RasterRegionCombineMode combineMode )
'Declaration Public Shared Sub AddGdiPlusDataToRegion( _ ByVal image As RasterImage, _ ByVal xform As RasterRegionXForm, _ ByVal data As RegionData, _ ByVal combineMode As RasterRegionCombineMode _ )
'Usage Dim image As RasterImage Dim xform As RasterRegionXForm Dim data As RegionData Dim combineMode As RasterRegionCombineMode RasterRegionConverter.AddGdiPlusDataToRegion(image, xform, data, combineMode)
public static void AddGdiPlusDataToRegion( RasterImage image, RasterRegionXForm xform, RegionData data, RasterRegionCombineMode combineMode )
function Leadtools.Drawing.RasterRegionConverter.AddGdiPlusDataToRegion( image , xform , data , combineMode )
public: static void AddGdiPlusDataToRegion( RasterImage^ image, RasterRegionXForm^ xform, RegionData^ data, RasterRegionCombineMode combineMode )
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+.
Public 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 image Using image As RasterImage = codecs.Load(srcFileName) ' Add a polygon region to it ' Add a polygon region to the image Dim x1 As Integer = image.ImageWidth \ 4 Dim y1 As Integer = image.ImageHeight \ 4 Dim x2 As Integer = image.ImageWidth \ 3 Dim y2 As Integer = image.ImageHeight \ 3 Dim 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 object gdipRegionData = RasterRegionConverter.GetGdiPlusRegionData(image, Nothing) End Using ' Re-load the source image Using image As RasterImage = codecs.Load(srcFileName) ' Add the GDI+ region data we saved to it RasterRegionConverter.AddGdiPlusDataToRegion(image, Nothing, gdipRegionData, RasterRegionCombineMode.Set) ' Fill this region with Yellow Dim cmd As New FillCommand(RasterColor.FromKnownColor(RasterKnownColor.Yellow)) cmd.Run(image) ' Save this image codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24) End Using codecs.Dispose() End Sub
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 image using(RasterImage image = codecs.Load(srcFileName)) { // Add a polygon region to it // Add a polygon region to the image int 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 object gdipRegionData = RasterRegionConverter.GetGdiPlusRegionData(image, null); } // Re-load the source image using(RasterImage image = codecs.Load(srcFileName)) { // Add the GDI+ region data we saved to it RasterRegionConverter.AddGdiPlusDataToRegion(image, null, gdipRegionData, RasterRegionCombineMode.Set); // Fill this region with Yellow FillCommand cmd = new FillCommand(RasterColor.FromKnownColor(RasterKnownColor.Yellow)); cmd.Run(image); // Save this image codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24); } 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