LEADTOOLS Annotations (Leadtools.Annotations assembly)

Draw(RasterImage) Method

Show in webframe
Example 





The Leadtools.RasterImage object on which to draw this AnnContainer.
Draws the container on the surface of the specified Leadtools.RasterImage object.
Syntax
public virtual void Draw( 
   RasterImage image
)
'Declaration
 
Public Overloads Overridable Sub Draw( _
   ByVal image As RasterImage _
) 
'Usage
 
Dim instance As AnnContainer
Dim image As RasterImage
 
instance.Draw(image)

            

            
public:
virtual void Draw( 
   RasterImage^ image
) 

Parameters

image
The Leadtools.RasterImage object on which to draw this AnnContainer.
Remarks

All visible objects in this container will be drawn into the specified image.

The container objects might be scaled to fit into the image dimension. This method is the equivalent of calling Draw(Graphics, Rectangle) with the rectangle values set to 0, 0, image.ImageWidth, image.ImageHeight/>.

Internally this method will call RasterImage.CreateLeadDC, so the image must satisfy the requirement for that method.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Annotations
Imports Leadtools.Codecs
Imports Leadtools.WinForms

Private Sub ContainerDrawRasterImageExample()
   ' Load the image
   Dim codecs As New RasterCodecs()
   Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"))
   ' Create and set up the container
   Dim container As New AnnContainer()
   container.Bounds = New AnnRectangle(0, 0, image.ImageWidth, image.ImageHeight)
   container.UnitConverter = New AnnUnitConverter(image.XResolution, image.YResolution)

   ' add a few objects to the container
   Dim line As New AnnLineObject()
   line.Name = "Line1"
   line.Pen = New AnnPen(Color.Red, New AnnLength(1, AnnUnit.Pixel))
   line.StartPoint = New AnnPoint(10, 10, AnnUnit.Pixel)
   line.EndPoint = New AnnPoint(container.Bounds.Right - 10, container.Bounds.Bottom - 10, AnnUnit.Pixel)
   container.Objects.Add(line)

   Dim rect As New AnnRectangleObject()
   rect.Name = "Rectangle1"
   rect.Pen = New AnnPen(Color.Blue, New AnnLength(1, AnnUnit.Pixel))
   rect.Brush = New AnnSolidBrush(Color.White)
   rect.Bounds = New AnnRectangle(25, 25, 50, 50, AnnUnit.Pixel)
   container.Objects.Add(rect)

   ' Now paint the annotation onto the image surface
   container.Draw(image)

   ' Save the image to the output file
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Ocr1_CotainerDraw.tif"), RasterImageFormat.Tif, image.BitsPerPixel)

   ' Clean up
   container.Dispose()
   image.Dispose()
   codecs.Dispose()

End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Annotations;
using Leadtools.Codecs;
using Leadtools.WinForms;

private void ContainerDrawRasterImageExample()
{
   // Load the image
   RasterCodecs codecs = new RasterCodecs();
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir,"Ocr1.tif"));
   // Create and set up the container
   AnnContainer container = new AnnContainer();
   container.Bounds = new AnnRectangle(0, 0, image.ImageWidth, image.ImageHeight);
   container.UnitConverter = new AnnUnitConverter(image.XResolution, image.YResolution);

   // add a few objects to the container
   AnnLineObject line = new AnnLineObject();
   line.Name = "Line1";
   line.Pen = new AnnPen(Color.Red, new AnnLength(1, AnnUnit.Pixel));
   line.StartPoint = new AnnPoint(10, 10, AnnUnit.Pixel);
   line.EndPoint = new AnnPoint(container.Bounds.Right - 10, container.Bounds.Bottom - 10, AnnUnit.Pixel);
   container.Objects.Add(line);

   AnnRectangleObject rect = new AnnRectangleObject();
   rect.Name = "Rectangle1";
   rect.Pen = new AnnPen(Color.Blue, new AnnLength(1, AnnUnit.Pixel));
   rect.Brush = new AnnSolidBrush(Color.White);
   rect.Bounds = new AnnRectangle(25, 25, 50, 50, AnnUnit.Pixel);
   container.Objects.Add(rect);

   // Now paint the annotation onto the image surface
   container.Draw(image);

   // Save the image to the output file
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir,"Ocr1_CotainerDraw.tif"), RasterImageFormat.Tif, image.BitsPerPixel);

   // Clean up
   container.Dispose();
   image.Dispose();
   codecs.Dispose();

}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
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.