标签:control log gen lang event span 水印 prot 分享
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button ID="Button1" runat="server" Text="上传" /><br /> <asp:Image ID="Image1" runat="server" /> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Drawing; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Button1.Click += Button1_Click; //上传按钮点击事件 } //上传按钮点击事件 void Button1_Click(object sender, EventArgs e) { //1、创建画布 System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload1.FileContent); Graphics g = Graphics.FromImage(img); //2、选择画笔、颜色 Brush b = new SolidBrush(Color.WhiteSmoke); //3、设置字体,大小 Font f = new Font("黑体", 28); //4、编辑内容 string s = "南娜官方网站"; //5、绘画,设置位置 g.DrawString(s, f, b, 100, 100); //6、保存画好的图片 string path="Default"+FileUpload1.FileName; img.Save(Server.MapPath(path)); Image1.ImageUrl = path; } }
标签:control log gen lang event span 水印 prot 分享
原文地址:http://www.cnblogs.com/xiao55/p/6005713.html