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

Realize(BitmapSource) Method

Show in webframe
Example 





The System.Windows.Media.Imaging.BitmapSource object on which to draw this AnnContainer. Must not be null (Nothing in Visual Basic).
Draws the container on the surface of the specified bitmap source.
Syntax
public virtual BitmapSource Realize( 
   BitmapSource source
)
'Declaration
 
Public Overloads Overridable Function Realize( _
   ByVal source As BitmapSource _
) As BitmapSource
'Usage
 
Dim instance As AnnContainer
Dim source As BitmapSource
Dim value As BitmapSource
 
value = instance.Realize(source)

            

            
public:
virtual BitmapSource^ Realize( 
   BitmapSource^ source
) 

Parameters

source
The System.Windows.Media.Imaging.BitmapSource object on which to draw this AnnContainer. Must not be null (Nothing in Visual Basic).

Return Value

A System.Windows.Media.Imaging.BitmapSource object that contains the combination of the original source in source overlayed with the annotation objects of this container. This is a new bitmap source with the same size as source.
Remarks

To create a System.Windows.Media.Imaging.BitmapSource representation of an AnnContainer, you must first create a System.Windows.Media.Imaging.BitmapSource object, fill it with the required background color and then call Realize.

Note that this method does not perform any scaling or offsetting. The container will be rendered at location 0,0 and with size equals to the container current size (ActualWidth and ActualHeight). Hence, typically, source will have the same size as the container. Otherwise, if the size of source is smaller than the container size, the returned bitmap source will be clipped. You can however use the bitmap source returned from this method as the source for a combine operation with another bitmap source to offset or scale the representation of the objects.

To render this container on the surface of a LEADTOOLS Leadtools.RasterImage, use Realize(RasterImage).

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

Private Sub RealizeBitmapSourceExample(ByVal container As AnnContainer)
   Dim width As Integer = CType(container.ActualWidth, Integer)
   Dim height As Integer = CType(container.ActualHeight, Integer)
   Dim stride As Integer = (width * 32 + 7) \ 8
   Dim pixels(height * stride - 1) As Byte
   ' Create a bitmap source with the same size as the container, this is the background of the realize operation
   Dim backImage As BitmapSource = BitmapSource.Create( _
      width, _
      height, _
      96.0, _
      96.0, _
      PixelFormats.Pbgra32, _
      Nothing, _
      pixels, _
      stride)

   ' Render the container on the image
   Dim containerRender As BitmapSource = container.Realize(backImage)

   ' Save it to disk
   Using stream As FileStream = File.Create("C:\Users\Public\Documents\LEADTOOLS Images\ContainerRender.png")
      Dim encoder As New PngBitmapEncoder()
      encoder.Frames.Add(BitmapFrame.Create(containerRender))
      encoder.Save(stream)
   End Using
End Sub
using Leadtools;
using Leadtools.Windows.Annotations;
using Leadtools.Windows.Controls;
using Leadtools.Codecs;

private void RealizeBitmapSourceExample(AnnContainer container)
{
   int width = (int)container.ActualWidth;
   int height = (int)container.ActualHeight;
   int stride = (width * 32 + 7) / 8;
   byte[] pixels = new byte[height * stride];
   // Create a bitmap source with the same size as the container, this is the background of the realize operation
   BitmapSource backImage = BitmapSource.Create(
      width,
      height,
      96.0,
      96.0,
      PixelFormats.Pbgra32,
      null,
      pixels,
      stride);

   // Render the container on the image
   BitmapSource containerRender = container.Realize(backImage);

   // Save it to disk
   using(FileStream stream = File.Create(@"C:\Users\Public\Documents\LEADTOOLS Images\ContainerRender.png"))
   {
      PngBitmapEncoder encoder = new PngBitmapEncoder();
      encoder.Frames.Add(BitmapFrame.Create(containerRender));
      encoder.Save(stream);
   }
}
Requirements

Target Platforms

See Also

Reference

AnnContainer Class
AnnContainer Members
Overload List

 

 


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