Hi,
I need to know how to use the LoadAnnotationsFromXMP and SaveAnnotationsToXMP when saving and loading to a stream.
Kind Regards
Robert
'Part 1: Open image, add annot and save annotation to Stream object
Dim oGdPictureImaging As New GdPictureImaging
Dim ImageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("c:\001.tif")
Dim oAnnotationManager As New AnnotationManager
Dim annotStream As New IO.MemoryStream()
oAnnotationManager.InitFromGdPictureImage(ImageID)
Dim annot As AnnotationStickyNote = oAnnotationManager.AddStickyNoteAnnot(0, 0, 3, 3, "To Be Investigated")
annot.CanSelect = False
annot.Author = "John"
oAnnotationManager.SaveAnnotationsToXMP(annotStream)
oGdPictureImaging.ReleaseGdPictureImage(ImageID)
'Part 2 open a new image & load the previously saved annotation from the Stream object
ImageID = oGdPictureImaging.CreateGdPictureImageFromFile("c:\002.tif")
oAnnotationManager.InitFromGdPictureImage(ImageID)
oAnnotationManager.LoadAnnotationsFromXMP(annotStream)
oAnnotationManager.SaveAnnotationsToPage()
GdViewer1.DisplayFromGdPictureImage(ImageID) 'Display the image including annotation into a GdViewer object
annotStream.Dispose()<GdPictureAnnotationsContainer>
<PageAnnots>
<PageNo>1</PageNo>
<Content> [CONTENT OF THE FIRST STREAM HERE] </Content>
</PageAnnots>
<PageAnnots>
<PageNo>2</PageNo>
<Content> [CONTENT OF THE SECONDSTREAM HERE] </Content>
</PageAnnots>
</GdPictureAnnotationsContainer>
Dim annMan As New AnnotationManager
Dim i, x, PageNo As Integer
Dim info() As System.Reflection.PropertyInfo
Dim Anno1 As Object
Dim AllAnnos As String = ""
Dim Type As String
For PageNo = 1 To imageViewer.PageCount
imageViewer.DisplayPage(PageNo)
For i = 0 To imageViewer.GetAnnotationCount - 1
Dim NewAnnot As GdPicture.Annotation
NewAnnot = imageViewer.GetAnnotationFromIdx(i)
Select Case NewAnnot.GetAnnotationType
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeConnectedLines
Dim Anno As GdPicture.AnnotationConnectedLines
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationConnectedLines)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationConnectedLines"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeEllipse
Dim Anno As GdPicture.AnnotationEllipse
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationEllipse)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationEllipse"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeEmbeddedImage
Dim Anno As GdPicture.AnnotationEmbeddedImage
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationEmbeddedImage)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationEmbeddedImage"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeFreeHand
Dim Anno As GdPicture.AnnotationFreeHand
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationFreeHand)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationFreeHand"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeFreeHandHighlighter
Dim Anno As GdPicture.AnnotationFreeHandHighlighter
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationFreeHandHighlighter)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationFreeHandHighlighter"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeFreeHandPolygon
Dim Anno As GdPicture.AnnotationFreehandPolygon
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationFreehandPolygon)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationFreehandPolygon"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeLine
Dim Anno As GdPicture.AnnotationLine
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationLine)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationLine"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeLineArrow
Dim Anno As GdPicture.AnnotationLineArrow
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationLineArrow)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationLineArrow"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeLink
Dim Anno As GdPicture.AnnotationLink
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationLink)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationLink"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypePolygon
Dim Anno As GdPicture.AnnotationPolygon
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationPolygon)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationPolygon"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeRectangle
Dim Anno As GdPicture.AnnotationRectangle
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationRectangle)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationRectangle"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeRectangleHighlighter
Dim Anno As GdPicture.AnnotationRectangleHighlighter
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationRectangleHighlighter)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationRectangleHighlighter"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeRubberStamp
Dim Anno As GdPicture.AnnotationRubberStamp
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationRubberStamp)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationRubberStamp"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeStickyNote
Dim Anno As GdPicture.AnnotationStickyNote
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationStickyNote)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationStickyNote"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeText
Dim Anno As GdPicture.AnnotationText
Anno = DirectCast(imageViewer.GetAnnotationFromIdx(i), GdPicture.AnnotationText)
info = Anno.GetType().GetProperties()
Anno1 = Anno
Type = "AnnotationText"
Case GdPicture.Annotation.GdPictureAnnotationType.AnnotationTypeUndefined
Continue For
End Select
Dim strOut As String = ""
For x = 0 To UBound(info)
If x > 0 Then strOut &= "||"
strOut &= info(x).Name & "^^" & info(x).GetValue(Anno1, Nothing).ToString
Next
AllAnnos &= "**Page:" & PageNo & "&&Type=" & Type & "##" & strOut
Next
Next
Return to GdPicture XMP Annotations Plugin
Users browsing this forum: No registered users and 1 guest