如何在Asp.net中将面板保存为位图图像 [英] How To Save Panel As Bitmap Image In Asp.net

查看:77
本文介绍了如何在Asp.net中将面板保存为位图图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Asp.net中将面板保存为位图图像



任何人都可以告诉我如何将面板或部门保存为硬盘驱动器中的图像

网络表单。 IM使用VS2008。



提前使用。

DrawToBitmap 是一个功能用于Window应用程序。

How To Save Panel As Bitmap Image In Asp.net

Can Anyone Please Tell Me How To save Panel or division as a image on hard drive in
web forms . I M Using VS2008.

Thanx In Advance.
And DrawToBitmap Is A Function used for Window Applications.

推荐答案

我不太确定你想要实现的目标是什么,但我可以告诉你它不是简单的壮举。 ASP.NET呈现HTML,当浏览器收到HTML时,将HTML呈现为GUI。如果我理解正确,你想要将服务器端生成的部分HTML转换为图像(png,gif,tiff或其他)。为了正确地执行此操作,渲染引擎直到该任务将需要整个信息,这些信息也可用于浏览器(CSS,javascript,doctype等)。

制作长篇故事简而言之,所述页面的完整HTML输出必须由该呈现引擎加载和解释,这将为服务页面添加相当多的延迟。我想不出任何人为什么会在他们的网络服务器上施加这种压力的任何理由,但是如果你能解释你真正想要的东西,也许我们可以引导你到另一个解决方案。

< br $>
祝你好运,



-MRB
I'm not quite sure what you want to achieve by this as the ultimate goal, but I can tell you that it is not an easy feat. ASP.NET renders HTML which when received by the browser renders said HTML into a GUI. If I understand you correctly you want part of the HTML which is generated on the server side to be transformed into an image (png, gif, tiff or whatever). In order to do this correctly the rendering engine up to that task would need the whole information that would also be available to the browswer (CSS, javascript, doctype, etc.).
To make a long story short, the complete HTML output of said page would have to be loaded and interpreted by that rendering engine which would add quite some delay to serving your pages. I can't think of any good reason why anybody would put that kind of strain on their web server, but if you can explain what you are really after maybe we can guide you to another solution.

Best regards,

-MRB


这是解决方案的人------ -----------



使用System;

使用System.Collections.Generic;

使用System.Linq;

使用System.Web;

使用System.Web.UI;

使用System.Web.UI .WebControls;

使用System.IO;

使用System.Drawing;

使用System.Drawing.Text;

使用System.Collections;

使用System.ComponentModel;

使用System.Reflection;

使用System.Data;

使用System.Drawing.Drawing2D;

使用System.Drawing.Imaging;



使用System.Web.Security;



使用System.Web.UI.WebControls.WebParts;

usin g System.Web.UI.HtmlControls;



使用System.Text;

使用System.Web.SessionState;







System.Drawing.Image image = new Bitmap(800,100);

System.Drawing.Graphics graphic = Graphics.FromImage(image);



System.Drawing.Drawing2D.LinearGradientBrush lBrush = new LinearGradientBrush(new Rectangle(0,0,800) ,100),System.Drawing.Color.FromName(ddlbackcolor.Text),System.Drawing.Color.White,90);

//graphic.DrawRectangle(System.Drawing.Pens.Black, 1,1,988,198);

graphic.FillRectangle(lBrush,0,0,800,100);

Font font = new Font(DropDownListfontname.SelectedValue, Convert.ToInt32(DropDownListfontsize.SelectedValue),FontStyle.Bold);

// Image img = new System.Web.UI.WebControls.Image(ImageMap1);



graphic.DrawString(txtbannertext。 Text,font,Brushes.White,400,40);

image.Save(Server.MapPath(/)+/ test.bmp);
This Is The Solution Man-----------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Drawing;
using System.Drawing.Text;
using System.Collections;
using System.ComponentModel;
using System.Reflection;
using System.Data;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

using System.Web.Security;

using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Text;
using System.Web.SessionState;



System.Drawing.Image image = new Bitmap(800, 100);
System.Drawing.Graphics graphic = Graphics.FromImage(image);

System.Drawing.Drawing2D.LinearGradientBrush lBrush = new LinearGradientBrush(new Rectangle(0, 0, 800, 100), System.Drawing.Color.FromName(ddlbackcolor.Text), System.Drawing.Color.White, 90);
//graphic.DrawRectangle(System.Drawing.Pens.Black, 1, 1, 988, 198);
graphic.FillRectangle(lBrush, 0, 0, 800, 100);
Font font = new Font(DropDownListfontname.SelectedValue, Convert.ToInt32(DropDownListfontsize.SelectedValue), FontStyle.Bold);
//Image img = new System.Web.UI.WebControls.Image(ImageMap1);

graphic.DrawString(txtbannertext.Text, font, Brushes.White, 400, 40);
image.Save(Server.MapPath("/") + "/test.bmp");


这篇关于如何在Asp.net中将面板保存为位图图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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