Page 1 of 1
TextAnnotationData on the Left Bottom Position of an Image
Posted: Fri Jul 24, 2015 2:55 pm
by GHWels
Hallo Alex
I want to draw a TextAnnotationData on the Left Bottom Position of an Image.
Gunther
Re: TextAnnotationData on the Left Bottom Position of an Image
Posted: Fri Jul 24, 2015 4:53 pm
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
Re: TextAnnotationData on the Left Bottom Position of an Image
Posted: Sat Jul 25, 2015 2:21 am
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
Re: TextAnnotationData on the Left Bottom Position of an Image
Posted: Mon Jul 27, 2015 11:03 am
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
Re: TextAnnotationData on the Left Bottom Position of an Image
Posted: Mon Jul 27, 2015 11:41 am
by GHWels
Thank you, it works.
Gunther