SimpleShape.DrawToBitmap Method (Bitmap, Rectangle)

 

Supports rendering to the specified bitmap.

Namespace:   Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

public override void DrawToBitmap(
    Bitmap bitmap,
    Rectangle targetBounds
)
public:
virtual void DrawToBitmap(
    Bitmap^ bitmap,
    Rectangle targetBounds
) override
override DrawToBitmap : 
        bitmap:Bitmap *
        targetBounds:Rectangle -> unit
Public Overrides Sub DrawToBitmap (
    bitmap As Bitmap,
    targetBounds As Rectangle
)

Parameters

Remarks

If the x or y coordinates or the width or height parameters of targetBounds are less than 0, an ArgumentException is thrown.

Examples

The following example demonstrates how to use the DrawToBitmap method and the ClientRectangle property to draw an OvalShape on a PictureBox control.

private void form1_Load(System.Object sender, System.EventArgs e)
{
    System.Drawing.Bitmap pic = new System.Drawing.Bitmap(this.pictureBox1.Image, 
        pictureBox1.Width, pictureBox1.Height);
    System.Drawing.Rectangle rect = new System.Drawing.Rectangle();
    // Assign the client rectangle.
    rect = ovalShape1.ClientRectangle;
    // Draw the oval on the bitmap.
    ovalShape1.DrawToBitmap(pic, rect);
    pictureBox2.Image = pic;
}
Private Sub Form1_Load() Handles MyBase.Load
    Dim pic As New System.Drawing.Bitmap(Me.PictureBox1.Image, 
      PictureBox1.Width, PictureBox1.Height)
    Dim rect As New System.Drawing.Rectangle
    ' Assign the client rectangle.
    rect = OvalShape1.ClientRectangle
    ' Draw the oval on the bitmap.
    OvalShape1.DrawToBitmap(pic, rect)
    PictureBox2.Image = pic
End Sub

See Also

SimpleShape Class
Microsoft.VisualBasic.PowerPacks Namespace
Introduction to the Line and Shape Controls (Visual Studio)
How to: Draw Lines with the LineShape Control (Visual Studio)
How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

Return to top