在我的C#Windows應用程序,我成功地使用下面的代碼捕獲DIV作爲圖像 - C#
int x1 = SystemInformation.WorkingArea.X;
int y1 = SystemInformation.WorkingArea.Y;
int width1 = panel1.Width;
int height1 = panel1.Height;
Rectangle bounds1 = new Rectangle(x1, y1, width1, height1);
Bitmap img1 = new Bitmap(width1, height1);
panel1.DrawToBitmap(img1, bounds1);
拍攝PANEL1作爲圖像(BMP,JPG,PNG),我用這個代碼在我的ASP網站捕獲asp面板作爲圖像。但SystemInformation
和DrawToBitmap
在web項目中不起作用。任何人都可以給我一個想法,如何捕捉具有實際寬度和高度的ASP面板。下面
private void savetypebtn_Click(object sender, EventArgs e)
{
try
{
int x1 = SystemInformation.WorkingArea.X;
int y1 = SystemInformation.WorkingArea.Y;
int width1 = panel1.Width;
int height1 = panel1.Height;
Rectangle bounds1 = new Rectangle(x1, y1, width1, height1);
Bitmap img1 = new Bitmap(width1, height1);
panel1.DrawToBitmap(img1, bounds1);
string saved_file = "";
savedialog.InitialDirectory = "D:";
savedialog.Title = "Save Quotation";
savedialog.FileName = "";
savedialog.Filter = "Jpg image|*.jpg|Bitmap image|*.bmp|png image|*.png";
if (savedialog.ShowDialog() != DialogResult.Cancel)
{
saved_file = savedialog.FileName;
img1.Save(saved_file, System.Drawing.Imaging.ImageFormat.Bmp);
}
}
catch (Exception ex)
{
errorlbl.Visible=True;
errorlbl.Text = ex.Message;
}
.net 4.0後不支持DrawToBitmap –