مشاركة عبر


Shape.DrawToBitmap Method

Supports rendering to the specified bitmap.

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

Syntax

'إقرار
Public MustOverride Sub DrawToBitmap ( _
    bitmap As Bitmap, _
    targetBounds As Rectangle _
)
'الاستخدام
Dim instance As Shape
Dim bitmap As Bitmap
Dim targetBounds As Rectangle

instance.DrawToBitmap(bitmap, targetBounds)
public abstract void DrawToBitmap(
    Bitmap bitmap,
    Rectangle targetBounds
)
public:
virtual void DrawToBitmap(
    Bitmap^ bitmap, 
    Rectangle targetBounds
) abstract
abstract DrawToBitmap : 
        bitmap:Bitmap * 
        targetBounds:Rectangle -> unit 
public abstract function DrawToBitmap(
    bitmap : Bitmap, 
    targetBounds : Rectangle
)

Parameters

Remarks

If the X or Y coordinates or the Width or Height parameters of targetBounds are less than 0, an ArgumentException will be thrown.

Examples

The following example demonstrates how to use the DrawToBitmap method to draw a LineShape on top of a PictureBox control.

Dim pic As New System.Drawing.Bitmap(Me.PictureBox1.Image,
 PictureBox1.Width, PictureBox1.Height)
Dim rect As New System.Drawing.Rectangle(LineShape1.X1,
    LineShape1.Y1, LineShape1.X2 - LineShape1.X1,
    LineShape1.Y2 - LineShape1.Y1)
LineShape1.DrawToBitmap(pic, rect)
PictureBox2.Image = pic
System.Drawing.Bitmap pic = new System.Drawing.Bitmap(this.pictureBox1.Image, 
    pictureBox1.Width, pictureBox1.Height);
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(lineShape1.X1, 
    lineShape1.Y1, lineShape1.X2 - lineShape1.X1, lineShape1.Y2 - lineShape1.Y1);
lineShape1.DrawToBitmap(pic, rect);
pictureBox2.Image = pic;

.NET Framework Security

See Also

Reference

Shape Class

Shape Members

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

How to: Draw Lines with the LineShape Control (Visual Studio)

How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

Introduction to the Line and Shape Controls (Visual Studio)