The Draw(RasterImage) Method is available in LEADTOOLS Document and Medical Imaging toolkits.
- image
- The Leadtools.RasterImage object on which to draw this AnnContainer.
Visual Basic (Declaration) | |
---|---|
Overloads Public Overridable Sub Draw( _ ByVal image As RasterImage _ ) |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As AnnContainer Dim image As RasterImage instance.Draw(image) |
C# | |
---|---|
public virtual void Draw( RasterImage image ) |
C++/CLI | |
---|---|
public: virtual void Draw( RasterImage^ image ) |
Parameters
- image
- The Leadtools.RasterImage object on which to draw this AnnContainer.
This example will create a container, adds a few annotations objects then burn them on the surface of a Leadtools.RasterImage object.
Visual Basic | Copy Code |
---|---|
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 |
C# | Copy Code |
---|---|
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"; } |
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.
Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7