TextAnnotationData on the Left Bottom Position of an Image

Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.

Moderator: Alex

Post Reply
GHWels
Posts: 38
Joined: Thu Apr 09, 2015 7:57 am

TextAnnotationData on the Left Bottom Position of an Image

Post by GHWels »

Hallo Alex

I want to draw a TextAnnotationData on the Left Bottom Position of an Image.

Gunther
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: TextAnnotationData on the Left Bottom Position of an Image

Post by Alex »

Hello Gunther,

Do you want to draw annotation using mouse or programmatically?

Please see code samples here: viewforum.php?f=24
and let me know if code samples do not help you.

Best regards, Alexander
GHWels
Posts: 38
Joined: Thu Apr 09, 2015 7:57 am

Re: TextAnnotationData on the Left Bottom Position of an Image

Post by GHWels »

Hallo Alex!

I have seen the code, but the position is not correct.

Viewer.Size = New Size(Viewer.Images(0).Width, Viewer.Images(0).Height)

Dim Data As New TextAnnotationData()
Data.Text = Datum.ToString("dd.MM.yyyy HH:mm")
.
.
.
Data.Location = New PointF(Data.Size.Width / 2 + 5, Viewer.Height - 5)
Viewer.AddAndBuildAnnotation(Data)

Gunther
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: TextAnnotationData on the Left Bottom Position of an Image

Post by Alex »

Hello Gunther,

All locations and sizes of annotations are specified in device-independent untis (1/96th inch per unit).

Here is a code snippet that shows how to create text annotation at thw left bottom position of image:

Code: Select all

// get reference to the first image
VintasoftImage image = annotationViewer1.Images[0];
// calculate image height in device-independent pixels (1/96th inch per unit)
float imageHeightInDIP = image.Height / image.Resolution.Vertical * 96f;

// create text annotation
TextAnnotationData textAnnoData = new TextAnnotationData();
textAnnoData.Text = "Test!";
textAnnoData.Font.Size = 36;
textAnnoData.Size = new SizeF(300, 200);
textAnnoData.Location = new PointF(textAnnoData.Size.Width / 2, imageHeightInDIP - textAnnoData.Size.Height / 2);
            
// create text annotation view
TextAnnotationView textAnnoView = new TextAnnotationView(textAnnoData);

// get reference to annotation view collection of first image
AnnotationViewCollection annoViews = annotationViewer1.AnnotationViewController[0];
// add text annotation view to annotation view collection of first image
annoViews.Add(textAnnoView);
Best regards, Alexander
GHWels
Posts: 38
Joined: Thu Apr 09, 2015 7:57 am

Re: TextAnnotationData on the Left Bottom Position of an Image

Post by GHWels »

Thank you, it works.
Gunther
Post Reply