How to Add Polygon Annotation on C# Image

C# Code Tutorial on How to Add Polygon Annotation onto Images in .NET Projects
Polygon annotation is just one of the many objects supported by Yiigo image annotation component DLL. Furthermore, this annotation library is a composing control of the Yiigo.Image for .NET SDK, developed for complete image & document processing and manipulating purpose.
With this annotation component, users can easily add polygon annotations on jpg/jpeg, gif, png, tiff image files and other documents, such as PDF, DOCX, XLSX, PPTX, etc. You can also customize the annotation outline color, width, polygon angle and size, background color, transparency, etc. Please follow the simple Visual C# tutorial below for polygon annotation processing on images.
How to Add Polygon Annotation on C# Image

C# Image Polygon Annotation - Requirements

  • .NET 2.0 or above versions.
  • .NET 2.0 or later versions.
  • MS Visual Studio 2005 or above / VS Express.
  • Visual C#.NET programming language

Annotate Polygon on C# Image - Getting Started

  • Download the Yiigo image SDK library, and unzip the package to run the setup file.
  • Activate your purchased license with your serial number. Or request an evaluation license and then activate it by following the wizard.

How to Draw a C# Polygon Annotation on Image

  • Start your Visual Studio and open your C# image project.
  • Add the annotation library to your project reference: Yiigo.Image.Annotation.dll.
  • Copy the namespace and Visual C# sample code below to add a polygon annotation on your png image.
  • Now you have successfully created a blue-backgrounded six-side Polygon with data text "Polygon" in it.
  • You can also create a multi-side polygon annotation by left-clicking the mouse for each point, and then right clicking to stop editing.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using Yiigo.Image.Annotation;

PolygonAnnotation myAnnotation = new PolygonAnnotation();
myAnnotation.Text = "Polygon";
myAnnotation.Sides = 6;
myAnnotation.FillBackground = true;
myAnnotation.FillColor = new AnnotationBrush(Color.Blue);
myAnnotation.Width = 10;
myAnnotation.Location = new PointF(100, 100);
myAnnotation.Size = new SizeF(80, 80);
myAnnotation.Opacity = 1;
annotationController1.CurrentLayer.Items.Add(myAnnotation);
  • To resize the annotation, change the sizing parameter in the C# code. Or in the viewer, select it by double clicking on it and then drag & release.
  • If you want to edit the text, simply edit the data for the "Text" property in the C# example above.
  • Those demonstrated above in the sample codes are just a few examples of polygon annotations for image in C#. To view more, check out the properties listed below.

Annotate Polygon on C# Image - Properties

  • Color: Color for the polygon outline. You can customize it with RGB value or simply select form the user defined color palette. Default is [0, 0, 0] black.
  • Width: The width for the polygon annotation outline. Default is 10 pixels.
  • Sides: The attribute indicating how many sides for the polygon image. Default is 5.
  • Fill Color: Color for the polygon image background. To set this color, you need to enable the Boolean property FillBackground to true beforehand. Default is [255, 255, 255] white.
  • Fill Background: A Boolean value to indicate whether to fill the polygon image background with color or not.
  • Opacity: Degree of transparency for the polygon image background color. Default is 1 meaning no transparency, i.e. no light passes through the image at all.

C# Image Polygon Annotation - Sample Image

Polygon Annotation
How to Annotate Images using C#
Products
Other Plugins
Image Viewer CoreBarcode PluginPDF Read & WriteTesseract OCR PluginForm Processing PluginJBIG2 CodecJPEG2000 CodecISIS ScannerTwain ScannerDICOM ReaderCAD Scanner