0

平台:UBUNTU
IDE:MonoDevelop 2.8.6.3
语言:C#.NET

我创建了一个函数,该函数制作屏幕截图并将该屏幕截图作为位图返回。像这样:

/* 存储位图数据的变量 */
Bitmap bmp;

/* 创建屏幕截图。返回结果到变量'bmp' */
getScreenShot(bmp);

我的问题是:

如何创建显示屏幕截图(即 bmp 数据)的表单/窗口(或任何有意义的)?我想以编程方式进行。

我试着这样做:

    public static void Main (string[] args)
    {

        Bitmap bmp = null;
        Form form = new Form
        {
            Name = "Screenshot Displayer",
            Size = new System.Drawing.Size(800, 800),
                            Location = new System.Drawing.Point(140, 170),
                             Visible=true
        };



        /* Get screenshot */
        Gdk.Global.InitCheck(ref args);
                    screenCapture.getScreenShot(bmp);

        form.BackgroundImage = bmp;
        form.Show();






    }

我也试过这个,但它不起作用。

PictureBox P = new PictureBox();  
Bitmap bmp = null;  
Form form = new Form  
{  
    Name = "Screenshot Displayer",  
    Size = new System.Drawing.Size(800, 800),  
    Location = new System.Drawing.Point(140, 170),  
    Visible=true  
};  

bmp = new Bitmap("screenshot0.bmp");  
P.Image = bmp;  
form.Controls.Add (P);  
form.Show();
4

2 回答 2

1

添加一个停靠填写表单的PictureBox。然后显示如下截图:

pictureBox1.Image=bmp;
于 2013-07-10T00:46:07.147 回答
0

“我如何创建一个显示屏幕截图(即 bmp 数据)的表单/窗口(或任何有意义的)?我想以编程方式进行。”

试试:(
编译下面应该显示你的Bitmap,研究代码并问什么):

//# Declare a PictureBox (as bitmap container)
PictureBox pbx;

//# Setup the PictureBox
pbx = new PictureBox
{
    Name = "pictureBox99",
    Size = new Size(640, 480),
    Location = new Point(0, 0),
    Visible=true
};

//# Link PictureBox to code for reference
this.Controls.Add(pbx);

// Add your Bitmap as source
pbx.Image = your_Bitmap_object;
于 2017-10-04T21:01:29.907 回答