呈现形式的位图 [英] Rendering form to bitmap

查看:100
本文介绍了呈现形式的位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想呈现形式为位图...是否有可能在.NET 2.0?

I would like to render Form to bitmap... Is it possible in .net 2.0?

推荐答案

当然,你可以叫 Control.DrawToBitmap()渲染控制位图。欲了解更多总图,你可以创建一个位图,然后用 Graphics.FromImage()来创建一个图形实例。然后,您可以绘制到该图形实例作为正常的。

Sure, you can call Control.DrawToBitmap() to render a control to a bitmap. For more general drawing, you can create a Bitmap and then use Graphics.FromImage() to create a Graphics instance. You can then draw to this graphics instance as normal.

下面是一个简单的形式,可以自行绘制(只需添加一个按钮,然后双击它以添加Click事件处理程序:

Here's a simple form that can draw itself (just add a button and double click it to add the Click event handler:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Bitmap b = new Bitmap(Width, Height);
        DrawToBitmap(b, new Rectangle(0, 0, Width, Height));
        b.Save("Test.bmp");
    }
}

这篇关于呈现形式的位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆