VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging Namespace / VintasoftImageGdiExtensions Class / Draw Methods / Draw(VintasoftImage,Graphics,Rectangle,Rectangle) Method
Syntax Example Requirements SeeAlso
In This Topic
    Draw(VintasoftImage,Graphics,Rectangle,Rectangle) Method (VintasoftImageGdiExtensions)
    In This Topic
    Draws this VintasoftImage on specified System.Drawing.Graphics object.
    Syntax
    'Declaration
    
    <ExtensionAttribute()>
    Public Overloads Shared Sub Draw( _
    ByVal image
    The image to draw.
    As VintasoftImage, _
    ByVal graphics
    The System.Drawing.Graphics object, where image must be drawn.
    As System.Drawing.Graphics, _
    ByVal destRect
    Rectangle structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle.
    As System.Drawing.Rectangle, _
    ByVal srcRect
    Rectangle structure that specifies the location and size of the drawn image.
    As System.Drawing.Rectangle _
    )

    Parameters

    image
    The image to draw.
    graphics
    The System.Drawing.Graphics object, where image must be drawn.
    destRect
    Rectangle structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle.
    srcRect
    Rectangle structure that specifies the location and size of the drawn image.
    Example

    This C#/VB.NET code shows how to overlay two images.

    
    ' open the original image
    Using originalImage As New Vintasoft.Imaging.VintasoftImage("c:\original-image.tif")
        ' open the overlay image
        Using overlayImage As New Vintasoft.Imaging.VintasoftImage("c:\overlay-image.tif")
            Dim g As System.Drawing.Graphics = Vintasoft.Imaging.VintasoftImageGdiExtensions.OpenGraphics(originalImage)
            ' draw the overlay image on the original image
            Vintasoft.Imaging.VintasoftImageGdiExtensions.Draw(overlayImage, g, New System.Drawing.Rectangle(300, 400, 500, 600), New System.Drawing.Rectangle(1000, 200, 1000, 700))
        End Using
    
        ' close Graphics of the overlay image
        Vintasoft.Imaging.VintasoftImageGdiExtensions.CloseGraphics(originalImage)
    
        ' save original image
        originalImage.Save("c:\processed-image.tif")
    End Using
    
    
    
    // open the original image
    using (Vintasoft.Imaging.VintasoftImage originalImage =
        new Vintasoft.Imaging.VintasoftImage(@"c:\original-image.tif"))
    {
        // open the overlay image
        using (Vintasoft.Imaging.VintasoftImage overlayImage =
            new Vintasoft.Imaging.VintasoftImage(@"c:\overlay-image.tif"))
        {
            System.Drawing.Graphics g = Vintasoft.Imaging.VintasoftImageGdiExtensions.OpenGraphics(originalImage);
            // draw the overlay image on the original image
            Vintasoft.Imaging.VintasoftImageGdiExtensions.Draw(overlayImage, g,
                                new System.Drawing.Rectangle(300, 400, 500, 600),
                                new System.Drawing.Rectangle(1000, 200, 1000, 700));
        }
    
        // close Graphics of the overlay image
        Vintasoft.Imaging.VintasoftImageGdiExtensions.CloseGraphics(originalImage);
    
        // save original image
        originalImage.Save(@"c:\processed-image.tif");
    }
    
    

    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