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 left As Single = 1, top As Single = 1, width As Single = 5, height As Single = 3, dist As Single = 0.2F
Dim annotRect As GdPicture14.Annotations.AnnotationRectangle = annotMgr.AddRectangleAnnot(Color.SteelBlue, Color.LightBlue, left, top, width, height)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRect IsNot Nothing) Then
annotRect.Author = "GdPicture"
annotRect.BorderWidth = 0.05F
annotRect.Opacity = 0.85F
End If
annotRect.Dispose()
If annotMgr.BurnAnnotationsToPage(True) = GdPictureStatus.OK Then
Dim annotRuler As GdPicture14.Annotations.AnnotationRuler = annotMgr.AddRulerAnnot(Color.Blue, left, top - dist, left + width, top - dist,
GdPicture14.Annotations.Annotation.UnitMode.Centimeter)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRuler IsNot Nothing) Then
annotRuler.Author = "GdPicture"
annotRuler.BorderWidth = 0.02F
annotRuler.FontSize = 10
annotRuler.Opacity = 1
End If
annotRuler.Dispose()
annotRuler = annotMgr.AddRulerAnnot(Color.Blue, left + width + dist, top, left + width + dist, top + height,
GdPicture14.Annotations.Annotation.UnitMode.Centimeter)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRuler IsNot Nothing) Then
annotRuler.Author = "GdPicture"
annotRuler.BorderWidth = 0.02F
annotRuler.FontSize = 10
annotRuler.Opacity = 1
End If
annotRuler.Dispose()
End If
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("rectangle.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("rectangle.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddRectangleAnnot")
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 left = 1, top = 1, width = 5, height = 3, dist = 0.2f;
GdPicture14.Annotations.AnnotationRectangle annotRect = annotMgr.AddRectangleAnnot(Color.SteelBlue, Color.LightBlue, left, top, width, height);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRect != null))
{
annotRect.Author = "GdPicture";
annotRect.BorderWidth = 0.05f;
annotRect.Opacity = 0.85f;
}
annotRect.Dispose();
if (annotMgr.BurnAnnotationsToPage(true) == GdPictureStatus.OK)
{
GdPicture14.Annotations.AnnotationRuler annotRuler = annotMgr.AddRulerAnnot(Color.Blue, left, top - dist, left + width, top - dist,
GdPicture14.Annotations.Annotation.UnitMode.Centimeter);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRuler != null))
{
annotRuler.Author = "GdPicture";
annotRuler.BorderWidth = 0.02f;
annotRuler.FontSize = 10;
annotRuler.Opacity = 1;
}
annotRuler.Dispose();
annotRuler = annotMgr.AddRulerAnnot(Color.Blue, left + width + dist, top, left + width + dist, top + height,
GdPicture14.Annotations.Annotation.UnitMode.Centimeter);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRuler != null))
{
annotRuler.Author = "GdPicture";
annotRuler.BorderWidth = 0.02f;
annotRuler.FontSize = 10;
annotRuler.Opacity = 1;
}
annotRuler.Dispose();
}
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("rectangle.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("rectangle.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddRectangleAnnot");