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: 32
Joined: Thu Apr 09, 2015 7:57 am

TextAnnotationData on the Left Bottom Position of an Image

Post by GHWels » Fri Jul 24, 2015 2:55 pm

Hallo Alex

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

Gunther
Best regards, GHWels

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

Re: TextAnnotationData on the Left Bottom Position of an Image

Post by Alex » Fri Jul 24, 2015 4:53 pm

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: 32
Joined: Thu Apr 09, 2015 7:57 am

Re: TextAnnotationData on the Left Bottom Position of an Image

Post by GHWels » Sat Jul 25, 2015 2:21 am

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
Best regards, GHWels

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

Re: TextAnnotationData on the Left Bottom Position of an Image

Post by Alex » Mon Jul 27, 2015 11:03 am

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: 32
Joined: Thu Apr 09, 2015 7:57 am

Re: TextAnnotationData on the Left Bottom Position of an Image

Post by GHWels » Mon Jul 27, 2015 11:41 am

Thank you, it works.
Gunther
Best regards, GHWels

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest