Hallo Alex
I want to draw a TextAnnotationData on the Left Bottom Position of an Image.
Gunther
TextAnnotationData on the Left Bottom Position of an Image
Moderator: Alex
-
- Posts: 40
- Joined: Thu Apr 09, 2015 7:57 am
-
- Site Admin
- Posts: 2397
- Joined: Thu Jul 10, 2008 2:21 pm
Re: TextAnnotationData on the Left Bottom Position of an Image
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
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
-
- Posts: 40
- Joined: Thu Apr 09, 2015 7:57 am
Re: TextAnnotationData on the Left Bottom Position of an Image
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
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
-
- Site Admin
- Posts: 2397
- Joined: Thu Jul 10, 2008 2:21 pm
Re: TextAnnotationData on the Left Bottom Position of an Image
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:
Best regards, Alexander
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);
-
- Posts: 40
- Joined: Thu Apr 09, 2015 7:57 am
Re: TextAnnotationData on the Left Bottom Position of an Image
Thank you, it works.
Gunther
Gunther