平臺:UBUNTU
IDE:MonoDevelop的2.8.6.3
語言:C#.NET以編程方式在窗體中創建窗體並顯示位圖?
我創建了一個功能,這使得截圖並返回該截圖爲位圖。像這樣:
/*用於存儲位圖數據的變量*/
位圖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();
你能告訴我一個例子?我嘗試了你的建議,但它不起作用。 – user1884325
PictureBox P = new PictureBox(); 位圖bmp = null; 表格形式=新形態 { 名稱= 「截圖顯示儀」, 大小=新System.Drawing.Size(800,800), 位置=新System.Drawing.Point(140,170), 可見=真 }; bmp = new Bitmap(@「example.bmp」); P.Image = bmp; P.Dock = DockStyle.Fill; form.Controls.Add(P); form.Show(); – user2492798
如果你不想在窗體上有一個圖片框,並且想要在窗體上繪製它,就像在表單 –