AddFreeHandAnnot Method (AnnotationManager)
In This Topic
Adds a new GdPicture/XMP freehand annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified. A freehand annotation is a drawn line consisting of several connected line segments.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeFreeHand. You can change the annotation properties directly using the GdPicture14.Annotations.AnnotationFreeHand class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP freehand annotation on the selected page of the document currently handled by this AnnotationManager object.
Syntax
Parameters
- BorderColor
- A color object that defines the required color of the newly added freehand annotation.
It corresponds to the AnnotationFreeHand.StrokeColor property.
- Points
- An array of points, in inches, which determines the line segments to be connected.
Return Value
A GdPicture/XMP AnnotationFreeHand object. The newly added GdPicture/XMP freehand annotation.
Example
How to add a freehand annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim px As Single = 5, py As Single = 1, dx As Single = 2, dy As Single = 2
Dim points1 As PointF() = New PointF(4) {New PointF(px, py), New PointF(px + dx, py), New PointF(px + dx / 2, py + dy / 2),
New PointF(px + 3 * dx / 2, py + dy), New PointF(px - dx, py + dy)}
Dim annot As GdPicture14.Annotations.AnnotationFreeHand = annotMgr.AddFreeHandAnnot(Color.SteelBlue, points1)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.BorderWidth = 0.1F
annot.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash
annot.Opacity = 0.5F
End If
annot.Dispose()
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("freehand.jpeg", 75)
End If
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("freehand.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddFreeHandAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
float px = 5, py = 1, dx = 2, dy = 2;
PointF[] points1 = new PointF[5] { new PointF(px, py), new PointF(px+dx, py), new PointF(px+dx/2, py+dy/2),
new PointF(px+3*dx/2, py+dy), new PointF(px-dx, py+dy) };
GdPicture14.Annotations.AnnotationFreeHand annot = annotMgr.AddFreeHandAnnot(Color.SteelBlue, points1);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.BorderWidth = 0.1f;
annot.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
annot.Opacity = 0.5f;
}
annot.Dispose();
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("freehand.jpeg", 75);
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("freehand.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddFreeHandAnnot");
Example
How to add a freehand annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim px As Single = 5, py As Single = 1, dx As Single = 2, dy As Single = 2
Dim points1 As PointF() = New PointF(4) {New PointF(px, py), New PointF(px + dx, py), New PointF(px + dx / 2, py + dy / 2),
New PointF(px + 3 * dx / 2, py + dy), New PointF(px - dx, py + dy)}
Dim annot As GdPicture14.Annotations.AnnotationFreeHand = annotMgr.AddFreeHandAnnot(Color.SteelBlue, points1)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.BorderWidth = 0.1F
annot.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash
annot.Opacity = 0.5F
End If
annot.Dispose()
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("freehand.jpeg", 75)
End If
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("freehand.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddFreeHandAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
float px = 5, py = 1, dx = 2, dy = 2;
PointF[] points1 = new PointF[5] { new PointF(px, py), new PointF(px+dx, py), new PointF(px+dx/2, py+dy/2),
new PointF(px+3*dx/2, py+dy), new PointF(px-dx, py+dy) };
GdPicture14.Annotations.AnnotationFreeHand annot = annotMgr.AddFreeHandAnnot(Color.SteelBlue, points1);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.BorderWidth = 0.1f;
annot.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
annot.Opacity = 0.5f;
}
annot.Dispose();
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("freehand.jpeg", 75);
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("freehand.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddFreeHandAnnot");
See Also