Home : Load Annotations from Jpeg or Tiff
Q10308 - HOWTO: Load Annotations from Jpeg or Tiff

This article is designed to do the loading when using this article’s Save() methodology http://www.atalasoft.com/KB/article.aspx?id=10274&cNode=0I8H4F

To  load annotations from an embedded source (either Tiff or Jpeg), the LayerCollection must be Imported from the stream. Here is a method to convert from the stream to an object that contains a ImageCollection and a LayerCollection:

C#

public AnnotationLoadResults Load(System.IO.Stream s)

{

     XmpAnnotationDataImporter imp = new XmpAnnotationDataImporter(s);

     AnnotationDataCollection data = imp.Import();

     LayerCollection layers = ConvertToLayerCollection(data);

     return new AnnotationLoadResults(new ImageCollection(s, null), layers);

}

VB.NET

Public Function Load(ByVal s As System.IO.Stream) As AnnotationLoadResults

    Dim imp As New XmpAnnotationDataImporter(s)

    Dim data As AnnotationDataCollection = imp.Import()

    Dim layers As LayerCollection = ConvertToLayerCollection(data)

    Return New AnnotationLoadResults(New ImageCollection(s, Nothing), layers)

End Function

 

 

After the import is performed the data comes in as an AnnotationDataCollection object. This method shows how to convert from an AnnotationDataCollection to a LayerCollection:

C#

public LayerCollection ConvertToLayerCollection(AnnotationDataCollection data)

{

    LayerCollection layers = new LayerCollection();

    foreach (LayerData layerdata in data)

    {

        LayerAnnotation layer = new LayerAnnotation(layerdata);

        layer.CreateAnnotationUIObjects(new AnnotationUIFactoryCollection());

        layers.Add(layer);

    }

    return layers;

}

VB.NET

Public Function ConvertToLayerCollection(ByVal data As AnnotationDataCollection) As LayerCollection

    Dim layers As New LayerCollection()

    For Each layerdata As LayerData In data

        Dim layer As New LayerAnnotation(layerdata)

        layer.CreateAnnotationUIObjects(New AnnotationUIFactoryCollection())

        layers.Add(layer)

    Next

    Return layers

End Function

 

 

Here is the code for the object that is used to return the results in the first method in this example:

C#

public class AnnotationLoadResults

{

 public AnnotationLoadResults(ImageCollection imgcol, LayerCollection laycol)

 {

     Images = imgcol;

     Layers = laycol;

  }

  public ImageCollection Images;

  public LayerCollection Layers;

}

 

VB.NET

Public Class AnnotationLoadResults

    Public Sub New(ByVal imgcol As ImageCollection, ByVal laycol As LayerCollection)

        Images = imgcol

        Layers = laycol

    End Sub

    Public Images As ImageCollection

    Public Layers As LayerCollection

End Class

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.

Powered By InstantKB.NET v1.3
Copyright © 2002, 2017. InstantASP Ltd. All Rights Reserved