平台: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();