Add Line Annotation onto C# Images

C# Sample Coding to Create Line Annotation on Images in .NET Projects
Line Annotation is one of the many objects supported by Yiigo image annotation component library. Other annotations are supported such as callout, ellipse, rectangle, rubberstamp, freehand, text and hotspot. Besides adding annotation, developers can also enjoy more image processing features with Yiigo.Image for .NET toolkit, such as image creating, scanning, OCR, document image conversion, cleaning-up and more.
This page will concentrate on Line Annotation only. By following the guiding steps below, developers will learn how to add line annotation in an image using Visual C# coding. You will be able to control line direction by specifying the start point and end point, set outline width and color, remove / resize it, etc.
Add Line Annotation on Images Using C#

C# Image Text Annotation - Requirements & Preparation

  • Microsoft Visual Studio 2005 or above / Visual Studio Express installed on your system
  • .NET Framework 2.0 or later versions
  • Download the .NET image SDK and unzip. Click on the exe file to run for installation.
  • When installation is done, activate either your ordered license or the 30-day evaluation license.

Draw a C# Line Annotation on Images

  • Now start your MS Visual Studio and click on your .NET image project to open.
  • Click "Project" - "Add Reference..." to add the Yiigo.Image.UI.Annotation.dll to your reference.
  • Copy the Visual C# sample code below to your project to create a line annotation on your image.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using Yiigo.Image.Annotation;

private void InitializeDefaultAnnotations()
{
// Draw a line annotation in your C#.NET project.
LineAnnotation lineAnnotation = new LineAnnotation ();
lineAnnotation.Name = "LineDemo1";

// Set the line color and outline width.
lineAnnotation.Width = 3;
lineAnnotation.Color = Color.Red;

// Specify the location of the line annotation.
lineAnnotation. StartPoint = (65, 20);
lineAnnotation. EndPoint = (155, 20);

annotationController1.CurrentLayer.Items.Add(lineAnnotation);
}
  • Run your project and you can see that a horizontal line with the width of 3 pixels is drawn on your sample png image.
  • For more settings such as line style and resizing options please view the property section below.

C# Image Text Annotation - Property Settings

  • Type stands for the line annotation type. Default is solid. You can also select dotted lines, etc.
  • StartPoint specifies the X and Y coordinates of the text annotation in the image/document space.
  • EndPoint specifies the X and Y coordinates of the text annotation in the image/document space
  • Resizable is a Boolean that represents whether developers can resize the line annotation, such as through the grips or a pinch-zoom gesture.
  • Selectable is Boolean that defines whether the line annotation can be selected. If set to false, you cannot remove or resize the line annotation.
  • Color is used to represent the line color. Users are able to manipulate it with the color name supported by the CSS color specification, or with RGB color value. Default is black [0, 0, 0]

C# Image Line Annotation - Sample Image

Line Annotation Sample
More C# Image Annotations Sample
Yiigo.Image for C#
Yiigo.Image Plugins
Image Viewer CoreBarcode PluginPDF Read & WriteTesseract OCR PluginForm Processing PluginJBIG2 CodecJPEG2000 CodecISIS ScannerTwain ScannerDICOM ReaderCAD Scanner