C# DrawToBitmap 方法

支持呈现到指定的位图。

命名空间:System.Windows.Forms
程序集:System.Windows.Forms(在 system.windows.forms.dll 中)

语法

public void DrawToBitmap (  Bitmap bitmap,  Rectangle targetBounds ) 
参数
bitmap 要绘制到的位图。
targetBounds 呈现控件时的边界。

ActiveX 控件不支持 DrawToBitmap 方法。如果需要,您可以重写 OnPrint 事件并提供自定义打印逻辑。

DrawToBitmap 方法具有下列局限性:

  • 可能会针对大位图引发 ArgumentException。允许使用的最大大小因计算机而异。

  • DrawToBitmap 不支持 Windows XP Tablet PC Edition 2005 操作系统的 Ink 控件。

  • 如果 TextBoxVisible 属性设置为 false,则 DrawToBitmap 不绘制子 TextBox

  • 容器内部的控件按相反的顺序呈现。

  • 对于 RichTextBoxDrawToBitmap 不能完全发挥作用;只绘制位图的边框。

    如果 x 或 y 坐标或者 targetBounds 的 width 或 height 参数小于 0,则引发 ArgumentException

    示例
    下面的示例演示如何使用 DrawToBitmap 方法和 ClientRectangle 属性在 PictureBox 控件上绘制一个 OvalShape
    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; }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值