根据您给的DEMO,还是无法添加注释,麻烦帮我看看代码,谢谢
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Load the default image
Dim defaultFileName As String = Path.Combine(DemosGlobal.ImagesFolder, "Image4.TIF")
'Dim defaultFileName As String = Path.Combine(DemosGlobal.ImagesFolder, "OCR1.TIF")
If Not String.IsNullOrEmpty(defaultFileName) AndAlso File.Exists(defaultFileName) Then
_imageViewer.ScrollMode = ControlScrollMode.Auto
_imageViewer.Image = _rasterCodecs.Load(defaultFileName)
End If
Dim newLr As LeadRect = _imageViewer.Image.GetRegion(RasterRegionXForm.Default).GetBounds()
Dim newLrD2 As LeadRectD = New LeadRectD(newLr.X, newLr.Y, newLr.Width, newLr.Height)
Dim text As AnnTextObject = New AnnTextObject()
text.Stroke = Nothing
text.Text = "aaaaaaaa"
text.Font = New AnnFont("Arial", 12)
text.Fill = Nothing
text.Rect = newLrD2
text.TextForeground = AnnSolidColorBrush.Create("Red")
Dim automationManager As New AnnAutomationManager
automationManager.RedactionRealizePassword = String.Empty
automationManager.EditContentAfterDraw = True
automationManager.EditTextAfterDraw = True
automationManager.EditObjectAfterDraw = True
automationManager.RestrictDesigners = True
automationManager.CreateDefaultObjects()
Dim automationControl As New ImageViewerAutomationControl
automationControl.ImageViewer = _imageViewer
Dim Automation As New AnnAutomation(automationManager, automationControl)
Automation.Container.Children.Add(text)
Automation.Invalidate(LeadRectD.Empty)
Automation.SelectObject(text)
Dim renderingEngine As AnnWinFormsRenderingEngine = New AnnWinFormsRenderingEngine()
Dim autoResetOptions As ImageViewerAutoResetOptions = _imageViewer.AutoResetOptions
_imageViewer.AutoResetOptions = ImageViewerAutoResetOptions.None
_imageViewer.Image = renderingEngine.RenderOnImage(Automation.Container, _imageViewer.Image)
_imageViewer.AutoResetOptions = autoResetOptions
End Sub
|