GdPicture.NET.14.API
GdPicture14 Namespace / AnnotationManager Class / InitFromGdPictureImage Method
A unique image identifier of the GdPictureImage object representing the required image. You can obtain this identifier, for example, using methods of the GdPictureImaging class when creating the image resource.

Be aware that this object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.

Example





In This Topic
InitFromGdPictureImage Method (AnnotationManager)
In This Topic
Initializes the current AnnotationManager object from a required GdPictureImage object identified by an unique image identifier. The document previously handled by this AnnotationManager object will automatically close.

Be aware that the AnnotationManager object only handles GdPicture/XMP annotations contained in the source image.

Syntax
'Declaration
 
Public Function InitFromGdPictureImage( _
   ByVal ImageID As Integer _
) As GdPictureStatus
public GdPictureStatus InitFromGdPictureImage( 
   int ImageID
)
public function InitFromGdPictureImage( 
    ImageID: Integer
): GdPictureStatus; 
public function InitFromGdPictureImage( 
   ImageID : int
) : GdPictureStatus;
public: GdPictureStatus InitFromGdPictureImage( 
   int ImageID
) 
public:
GdPictureStatus InitFromGdPictureImage( 
   int ImageID
) 

Parameters

ImageID
A unique image identifier of the GdPictureImage object representing the required image. You can obtain this identifier, for example, using methods of the GdPictureImaging class when creating the image resource.

Be aware that this object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Remarks

This method requires the Annotations component to run.

Example
How to initialize the AnnotationManager object from already initialized GdPictureImage object.
Dim oImage As GdPictureImaging = New GdPictureImaging()
Dim annotationManager As AnnotationManager = New AnnotationManager()
Dim imageID As Integer = oImage.CreateGdPictureImageFromFile("image.tiff")
If (oImage.GetStat() = GdPictureStatus.OK) AndAlso
   (annotationManager.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
   (annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
    Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
    If stamp IsNot Nothing Then
        stamp.Rotation = 20
        If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
           (annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) AndAlso
           (annotationManager.SaveDocumentToTIFF("image_approved.tiff", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK) Then
            MessageBox.Show("Finished successfully!", "AnnotationManager.InitFromGdPictureImage")
        Else
            MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdPictureImage")
        End If
        stamp.Dispose()
    Else
        MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdPictureImage")
    End If
    annotationManager.Close()
Else
    MessageBox.Show("Objects can't be initialized properly.", "AnnotationManager.InitFromGdPictureImage")
End If
annotationManager.Dispose()
oImage.ReleaseGdPictureImage(imageID)
oImage.Dispose()
GdPictureImaging oImage = new GdPictureImaging();
AnnotationManager annotationManager = new AnnotationManager();
int imageID = oImage.CreateGdPictureImageFromFile("image.tiff");
if ((oImage.GetStat() == GdPictureStatus.OK) &&
    (annotationManager.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
    (annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
    GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
    if (stamp != null)
    {
        stamp.Rotation = 20;
        if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
            (annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK) &&
            (annotationManager.SaveDocumentToTIFF("image_approved.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK))
            MessageBox.Show("Finished successfully!", "AnnotationManager.InitFromGdPictureImage");
        else
            MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdPictureImage");
        stamp.Dispose();
    }
    else
        MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdPictureImage");
    annotationManager.Close();
}
else
    MessageBox.Show("Objects can't be initialized properly.", "AnnotationManager.InitFromGdPictureImage");
annotationManager.Dispose();
oImage.ReleaseGdPictureImage(imageID);
oImage.Dispose();
See Also