VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.Drawing Namespace / DrawingEngine Class / DrawImage Methods / DrawImage(VintasoftImage,RectangleF) Method
Syntax Example Requirements SeeAlso
In This Topic
    DrawImage(VintasoftImage,RectangleF) Method (DrawingEngine)
    In This Topic
    Draws the specified VintasoftImage in the specified rectangle.
    Syntax

    Parameters

    image
    The VintasoftImage to draw.
    destRect
    The System.Drawing.RectangleF structure that specifies the location and size of the drawn image.
    Example

    Here is an example that shows how to draw image using drawing engine.

    
    ''' <summary>
    ''' Draws an image on specified drawing engine.
    ''' </summary>
    ''' <param name="drawingEngine">Drawing engine.</param>
    ''' <param name="area">Area to draw objects in.</param>
    Public Shared Sub DrawImageExample(drawingEngine As DrawingEngine, area As RectangleF)
        ' path to image file for drawing
        ' this image is located in <install path>/VintaSoft/Imaging .NET/Images/
        Dim imagePath As String = "AutoContrast.jpg"
    
        ' create VintaSoft image
        Using image As New VintasoftImage(imagePath)
            ' create transform holder to save current engine transform and restore it aftewards
            Using drawingEngine.CreateTransformHolder()
                ' create image destination rectangle
                Dim imageRect As New RectangleF(area.X + area.Width * 0.25F, area.Y + area.Height * 0.25F, area.Width / 2, area.Height / 2)
                ' apply rotation transform to drawing engine
                drawingEngine.Transform = AffineMatrix.CreateRotation(35, imageRect.X + imageRect.Width / 2, imageRect.Y + imageRect.Height / 2)
                ' draw image
                drawingEngine.DrawImage(image, imageRect)
            End Using
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Draws an image on specified drawing engine.
    /// </summary>
    /// <param name="drawingEngine">Drawing engine.</param>
    /// <param name="area">Area to draw objects in.</param>
    public static void DrawImageExample(DrawingEngine drawingEngine, RectangleF area)
    {
        // path to image file for drawing
        // this image is located in <install path>/VintaSoft/Imaging .NET/Images/
        string imagePath = "AutoContrast.jpg";
    
        // create VintaSoft image
        using (VintasoftImage image = new VintasoftImage(imagePath))
        // create transform holder to save current engine transform and restore it aftewards
        using (drawingEngine.CreateTransformHolder())
        {
            // create image destination rectangle
            RectangleF imageRect = new RectangleF(area.X + area.Width * 0.25f, area.Y + area.Height * 0.25f, area.Width / 2, area.Height / 2);
            // apply rotation transform to drawing engine
            drawingEngine.Transform = AffineMatrix.CreateRotation(35, imageRect.X + imageRect.Width / 2, imageRect.Y + imageRect.Height / 2);
            // draw image
            drawingEngine.DrawImage(image, imageRect);
        }
    }
    
    

    Requirements

    Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also