Leadtools.Annotations Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.10.31
AnnPicture Class
See Also  Members   Example 
Leadtools.Annotations Namespace : AnnPicture Class




Defines an annotation picture along with its transparency information.

Syntax

Visual Basic (Declaration) 
<SerializableAttribute()>
Public Class AnnPicture 
Visual Basic (Usage)Copy Code
Dim instance As AnnPicture
C# 
[SerializableAttribute()]
public class AnnPicture 
Managed Extensions for C++ 
[SerializableAttribute()]
public __gc class AnnPicture 
C++/CLI 
[SerializableAttribute()]
public ref class AnnPicture 

Example

This example creates an image that has a blue ellipse inside a red rectangle.

Visual BasicCopy Code
Private Sub AnnPicture_AnnPicture(ByVal g As Graphics)
   Dim btmp As Bitmap = New Bitmap(100, 100, PixelFormat.Format32bppArgb)
   Try
      Dim graphicsImage As Graphics = Graphics.FromImage(btmp)
      Try
         graphicsImage.FillRectangle(Brushes.Red, New Rectangle(0, 0, 100, 100))
         graphicsImage.FillEllipse(Brushes.Blue, New Rectangle(0, 0, 100, 100))
         graphicsImage.Dispose()
      Finally
         CType(graphicsImage, IDisposable).Dispose()
      End Try
      ' initialize a new AnnPicture class for this image
      Dim pic As AnnPicture = New AnnPicture(btmp)

      ' draw the picture with no transparency
      Dim rc As Rectangle = New Rectangle(10, 10, pic.Image.Width, pic.Image.Height)
      Dim ia As ImageAttributes = pic.ImageAttributes
      If Not ia Is Nothing Then
         g.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia)
         ia.Dispose()
      Else
         If rc.Width > 1 AndAlso rc.Height > 1 Then
            g.DrawImage(pic.Image, rc)
         End If
      End If

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

      ia = pic.ImageAttributes
      If Not ia Is Nothing Then
         g.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia)
         ia.Dispose()
      Else
         If rc.Width > 1 AndAlso rc.Height > 1 Then
            g.DrawImage(pic.Image, rc)
         End If
      End If

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

      ia = pic.ImageAttributes
      If Not ia Is Nothing Then
         g.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia)
         ia.Dispose()
      Else
         If rc.Width > 1 AndAlso rc.Height > 1 Then
            g.DrawImage(pic.Image, rc)
         End If
      End If
   Finally
      CType(btmp, IDisposable).Dispose()
   End Try
End Sub
C#Copy Code
private void AnnPicture_AnnPicture(Graphics graphics) 

   using(Bitmap btmp = new Bitmap(100, 100, PixelFormat.Format32bppArgb)) 
   { 
      using(Graphics graphicsImage = Graphics.FromImage(btmp)) 
      { 
         graphicsImage.FillRectangle(Brushes.Red, new Rectangle(0, 0, 100, 100)); 
         graphicsImage.FillEllipse(Brushes.Blue, new Rectangle(0, 0, 100, 100)); 
         graphicsImage.Dispose(); 
      } 
      // initialize a new AnnPicture class for this image 
      AnnPicture pic = new AnnPicture(btmp); 
 
      // draw the picture with no transparency 
      Rectangle rc = new Rectangle(10, 10, pic.Image.Width, pic.Image.Height); 
      ImageAttributes ia = pic.ImageAttributes; 
      if(ia != null) 
      { 
         graphics.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia); 
         ia.Dispose(); 
      } 
      else 
      { 
         if(rc.Width > 1 && rc.Height > 1) 
            graphics.DrawImage(pic.Image, rc); 
      } 
 
      // draw the picture without the ellipse (make transparent color = blue) 
      rc.Offset(0, pic.Image.Height + 10); 
      pic.TransparentMode = AnnPictureTransparentMode.UseColor; 
      pic.TransparentColor = Color.Blue; 
 
      ia = pic.ImageAttributes; 
      if(ia != null) 
      { 
         graphics.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia); 
         ia.Dispose(); 
      } 
      else 
      { 
         if(rc.Width > 1 && rc.Height > 1) 
            graphics.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 = AnnPictureTransparentMode.TopLeftPixel; 
 
      ia = pic.ImageAttributes; 
      if(ia != null) 
      { 
         graphics.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia); 
         ia.Dispose(); 
      } 
      else 
      { 
         if(rc.Width > 1 && rc.Height > 1) 
            graphics.DrawImage(pic.Image, rc); 
      } 
   } 
}

Inheritance Hierarchy

System.Object
   Leadtools.Annotations.AnnPicture

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Leadtools.Annotations requires a Document or Medical toolkit license and unlock key. For more information, refer to: Raster Pro/Document/Medical Features