LEADTOOLS Support
Document
Document SDK Examples
HOW TO: C# .NET Core Burn Annotations XML to Image
#1
Posted
:
Tuesday, April 7, 2020 4:13:20 PM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 105
Was thanked: 3 time(s) in 3 post(s)
The AnnRenderingEngine class allows the ability to burn an annotations container (AnnContainer) to an image.
The below C# code will showcase how to burn annotations in an XML file to a given image using the RenderOnImage() method:
Code:
private static AnnDrawRenderingEngine _renderingEngine;
static void Main(string[] args)
{
string licenseFilePath = @"C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.lic";
string developerKey = File.ReadAllText(@"C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.lic.key");
RasterSupport.SetLicense(licenseFilePath, developerKey);
_renderingEngine = new AnnDrawRenderingEngine();
BurnAnnotations();
}
private static void BurnAnnotations()
{
string inFile = @"PATH TO IMAGE";
string annFile = @"PATH TO ANNOTATION XML";
string outFile = @"PATH TO OUTPUT FILE";
using (RasterCodecs codecs = new RasterCodecs())
{
AnnCodecs annCodecs = new AnnCodecs();
AnnContainer container = new AnnContainer();
using (RasterImage image = codecs.Load(inFile))
{
container.Mapper.MapResolutions(image.XResolution, image.YResolution, image.XResolution, image.YResolution);
container.Size = container.Mapper.SizeToContainerCoordinates(image.ImageSize.ToLeadSizeD());
container = annCodecs.Load(annFile, 1);
using (var burnedImage = _renderingEngine.RenderOnImage(container, image))
codecs.Save(burnedImage, outFile, RasterImageFormat.Png, 0);
}
}
}
This is using the Leadtools.Annotations.NETStandard Nuget package:
Leadtools.Annotations.NETStandardRelevant LEADTOOLS v20 links:
Edited by moderator Tuesday, April 14, 2020 2:51:49 PM(UTC)
| Reason: Not specified
Matt Bresson
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK Examples
HOW TO: C# .NET Core Burn Annotations XML to Image
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.