Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, April 7, 2020 4:13:20 PM(UTC)
Matthew Bresson

Groups: Registered, Tech Support, Administrators
Posts: 34


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.NETStandard

Relevant LEADTOOLS v20 links:


File Attachment(s):
BurnAnnotationsDotNetCore.zip (2kb) downloaded 7 time(s).

Edited by moderator Tuesday, April 14, 2020 2:51:49 PM(UTC)  | Reason: Not specified

Matt Bresson
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

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.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.100 seconds.