LEADTOOLS Annotations for WPF and Silverlight (Leadtools.Windows.Annotations assembly)

AnnPicture Class

Show in webframe
Example 





Members 
Defines an annotation picture along with its transparency information.
Object Model
Syntax
public class AnnPicture : System.Windows.DependencyObject 
'Declaration
 
Public Class AnnPicture 
   Inherits System.Windows.DependencyObject
'Usage
 
Dim instance As AnnPicture

            

            
public ref class AnnPicture : public System.Windows.DependencyObject 
Example

For XAML example, refer to AnnGroupObject.

Copy Code  
Imports Leadtools.Windows.Controls
Imports Leadtools.Windows.Annotations

Private Sub AnnPicture_AnnPicture(ByVal dc As DrawingContext)
   Dim pic As AnnPicture = Nothing
   Dim dv As DrawingVisual = New DrawingVisual()
   Using dvc As DrawingContext = dv.RenderOpen()
      'Bitmap btmp = new Bitmap(100, 100, PixelFormat.Format32bppArgb))
      dvc.DrawRectangle(Brushes.Red, Nothing, New Rect(0, 0, 100, 100))
      dvc.DrawEllipse(Brushes.Red, Nothing, New System.Windows.Point(50, 50), 100, 100)
      dvc.Close()
      Dim btmp As RenderTargetBitmap = New RenderTargetBitmap(100, 100, 96, 96, PixelFormats.Pbgra32)
      btmp.Render(dv)

      ' initialize a new AnnPicture class for this image
      pic = New AnnPicture(btmp)
   End Using

   If Not pic Is Nothing AndAlso Not pic.Image Is Nothing Then
      ' draw the picture with no transparency
      Dim rc As Rect = New Rect(10, 10, pic.Image.Width, pic.Image.Height)
      dc.DrawImage(pic.Image, rc)

      ' draw the picture without the ellipse (make transparent color = blue)
      rc.Offset(0, pic.Image.Height + 10)
      pic.TransparentMode = AnnTransparentMode.UseColor
      pic.TransparentColor = Colors.Blue


      dc.DrawImage(pic.Image, rc)

      ' draw the picture without the rectangle (use the top left pixel as the transparent color)
      rc.Offset(0, pic.Image.Height + 10)
      pic.TransparentMode = AnnTransparentMode.TopLeftPixel

      dc.DrawImage(pic.Image, rc)
   End If
End Sub
using Leadtools.Windows.Controls;
using Leadtools.Windows.Annotations;
using Leadtools.Demos;
using Leadtools.Help;

private void AnnPicture_AnnPicture(DrawingContext dc)
{
   AnnPicture pic = null;
   DrawingVisual dv = new DrawingVisual();
   using(DrawingContext dvc = dv.RenderOpen())
   //Bitmap btmp = new Bitmap(100, 100, PixelFormat.Format32bppArgb))
   {
      dvc.DrawRectangle(Brushes.Red, null, new Rect(0, 0, 100, 100));
      dvc.DrawEllipse(Brushes.Red, null, new Point(50, 50), 100, 100);
      dvc.Close();
      RenderTargetBitmap btmp = new RenderTargetBitmap(100, 100, 96, 96, PixelFormats.Pbgra32);
      btmp.Render(dv);

      // initialize a new AnnPicture class for this image
      pic = new AnnPicture(btmp);
   }

   if(pic != null && pic.Image != null)
   {
      // draw the picture with no transparency
      Rect rc = new Rect(10, 10, pic.Image.Width, pic.Image.Height);
      dc.DrawImage(pic.Image, rc);

      // draw the picture without the ellipse (make transparent color = blue)
      rc.Offset(0, pic.Image.Height + 10);
      pic.TransparentMode = AnnTransparentMode.UseColor;
      pic.TransparentColor = Colors.Blue;


      dc.DrawImage(pic.Image, rc);

      // draw the picture without the rectangle (use the top left pixel as the transparent color)
      rc.Offset(0, pic.Image.Height + 10);
      pic.TransparentMode = AnnTransparentMode.TopLeftPixel;

      dc.DrawImage(pic.Image, rc);
   }
}
using Leadtools.Windows.Controls;
using Leadtools.Windows.Annotations;
using Leadtools.Examples;

private void AnnPicture_AnnPicture()
{
   AnnPicture pic = null;
   Canvas myCanvas = new Canvas();
   myCanvas.Width = 100;
   myCanvas.Height = 100;

   Rectangle rect = new Rectangle();
   rect.Fill = new SolidColorBrush(Colors.Red);
   rect.Width = 100;
   rect.Height = 100;
   myCanvas.Children.Add(rect);

   Ellipse elipse = new Ellipse();
   elipse.Fill = new SolidColorBrush(Colors.Red);
   elipse.Width = 100;
   elipse.Height = 100;
   myCanvas.Children.Add(elipse);

   WriteableBitmap wb = new WriteableBitmap(200, 200);
   wb.Render(myCanvas, null);
   wb.Invalidate();

   ImageSource img = wb;
   pic = new AnnPicture((BitmapSource)img);
}
Imports Leadtools.Windows.Controls
Imports Leadtools.Windows.Annotations

Private Sub AnnPicture_AnnPicture()
   Dim pic As AnnPicture = Nothing
   Dim myCanvas As Canvas = New Canvas()
   myCanvas.Width = 100
   myCanvas.Height = 100

   Dim rect As Rectangle = New Rectangle()
   rect.Fill = New SolidColorBrush(Colors.Red)
   rect.Width = 100
   rect.Height = 100
   myCanvas.Children.Add(rect)

   Dim elipse As Ellipse = New Ellipse()
   elipse.Fill = New SolidColorBrush(Colors.Red)
   elipse.Width = 100
   elipse.Height = 100
   myCanvas.Children.Add(elipse)

   Dim wb As WriteableBitmap = New WriteableBitmap(200, 200)
   wb.Render(myCanvas, Nothing)
   wb.Invalidate()

   Dim img As ImageSource = wb
   pic = New AnnPicture(CType(img, BitmapSource))
End Sub
Requirements

Target Platforms

See Also

Reference

AnnPicture Members
Leadtools.Windows.Annotations Namespace

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.