VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging.Annotation.Wpf.UI Namespace / WpfAnnotationViewer Class
Members Example



In This Topic
    WpfAnnotationViewer Class
    In This Topic
    Viewer control for displaying an image collection with annotations.
    Object Model
    WpfAnnotationViewer ClassAnnotationDataCollection ClassAnnotationData ClassAnnotationDataController ClassWpfRectangularSelectionTool ClassWpfAnnotationViewCollection ClassWpfAnnotationView ClassWpfAnnotationViewController ClassWpfAnnotationVisualTool ClassAnnotationData ClassWpfAnnotationView ClassVintasoftImage ClassDecodingSettings ClassRenderingSettings ClassImageCollection ClassVintasoftImage ClassWpfImageViewerBase ClassPaddingF StructureImageRenderingRequirements ClassWpfRotationAssistantArea ClassSelectedWpfAnnotationViewCollection ClassWpfAnnotationView ClassWpfImageViewerState ClassWpfVisualTool Class
    Syntax
    'Declaration
     
    <ToolboxBitmapAttribute()>
    Public Class WpfAnnotationViewer 
       Inherits Vintasoft.Imaging.Wpf.UI.WpfImageViewer
    [ToolboxBitmap()]
    public class WpfAnnotationViewer : Vintasoft.Imaging.Wpf.UI.WpfImageViewer 
    [ToolboxBitmap()]
    public __gc class WpfAnnotationViewer : public Vintasoft.Imaging.Wpf.UI.WpfImageViewer 
    [ToolboxBitmap()]
    public ref class WpfAnnotationViewer : public Vintasoft.Imaging.Wpf.UI.WpfImageViewer 
    Example
    This example shows how to open TIFF image in WPF image viewer, annotate TIFF image and save annotated TIFF image back to the source file.
    ''' <summary>
    ''' Open TIFF image in WPF image viewer,
    ''' annotates TIFF image and
    ''' saves annotated TIFF image back to the source file.
    ''' </summary>
    ''' <param name="filename">The filename of TIFF image.</param>
    ''' <param name="viewer">The annotation viewer.</param>
    Public Shared Sub OpenAndSaveTiffFile(filename As String, viewer As Vintasoft.Imaging.Annotation.Wpf.UI.WpfAnnotationViewer)
        ' open stream
        Using stream As System.IO.FileStream = System.IO.File.Open(filename, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite)
            ' add image to the image viewer
            viewer.Images.Add(stream)
                
            ' create annotation data
            Dim annoData As New Vintasoft.Imaging.Annotation.HighlightAnnotationData()
            annoData.Location = New System.Drawing.PointF(150, 150)
            annoData.Size = New System.Drawing.SizeF(300, 300)
                
            ' add annotation to an image
            viewer.AnnotationDataCollection.Add(annoData)
                
            ' create TIFF encoder
            Dim tiffEncoder As New Vintasoft.Imaging.Codecs.Encoders.TiffEncoder()
            tiffEncoder.SaveAndSwitchSource = True
            ' save TIFF image back to the source stream
            viewer.Images.SaveSync(stream, tiffEncoder)
                
            ' dispose image
            viewer.Images.ClearAndDisposeItems()
                
            ' close stream
            stream.Close()
        End Using
    End Sub
    /// <summary>
    /// Open TIFF image in WPF image viewer,
    /// annotates TIFF image and
    /// saves annotated TIFF image back to the source file.
    /// </summary>
    /// <param name="filename">The filename of TIFF image.</param>
    /// <param name="viewer">The annotation viewer.</param>
    public static void OpenAndSaveTiffFile(string filename, Vintasoft.Imaging.Annotation.Wpf.UI.WpfAnnotationViewer viewer)
    {
        // open stream
        using (System.IO.FileStream stream = System.IO.File.Open(
            filename, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite))
        {
            // add image to the image viewer
            viewer.Images.Add(stream);
                
            // create annotation data
            Vintasoft.Imaging.Annotation.HighlightAnnotationData annoData = 
                new Vintasoft.Imaging.Annotation.HighlightAnnotationData();
            annoData.Location = new System.Drawing.PointF(150, 150);
            annoData.Size = new System.Drawing.SizeF(300, 300);
            
            // add annotation to an image
            viewer.AnnotationDataCollection.Add(annoData);
                
            // create TIFF encoder
            Vintasoft.Imaging.Codecs.Encoders.TiffEncoder tiffEncoder = 
                new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder();
            tiffEncoder.SaveAndSwitchSource = true;
            // save TIFF image back to the source stream
            viewer.Images.SaveSync(stream, tiffEncoder);
                
            // dispose image
            viewer.Images.ClearAndDisposeItems();
                
            // close stream
            stream.Close();
        }
    }
    Inheritance Hierarchy

    System.Object
       System.Windows.Threading.DispatcherObject
          System.Windows.DependencyObject
             System.Windows.Media.Visual
                System.Windows.UIElement
                   System.Windows.FrameworkElement
                      System.Windows.Controls.Control
                         System.Windows.Controls.ContentControl
                            System.Windows.Controls.ScrollViewer
                               Vintasoft.Imaging.Wpf.UI.WpfImageViewerBase
                                  Vintasoft.Imaging.Wpf.UI.WpfImageViewer
                                     Vintasoft.Imaging.Annotation.Wpf.UI.WpfAnnotationViewer

    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also