谁知道怎么给上传的图片 加水印? 当我用 c# 写的组件 上传一张图片的时候,我要在图片的底部加上 “上传者某某”有谁知道怎么做吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <%@ Page Language="c#" Debug="true" Trace="true"%><%@ Import Namespace="System.IO" %><%@ Import Namespace="System.Drawing" %><%@ Import Namespace="System.Drawing.Imaging" %><html><script runat =server> void UploadBtn_Click(Object sender, EventArgs e) { String filename; String filename1; String[] filename2; int q; filename=UploadFile.PostedFile.FileName ; filename2=filename.Split(new Char[] {'\\'}); q=filename2.GetUpperBound(0); filename1=filename2[q]; dis.Text="上传文件名:"+filename1+"<br/>"; UploadFile.PostedFile.SaveAs(Server.MapPath(filename1)); ImageEditor.Visible = true; dis.Text+="文件大小:"+UploadFile.PostedFile.ContentLength+"字节数"; Image1.Src=filename1; } void UpdateBtn_Click(Object sender, EventArgs e) { String filename1; filename1=Image1.Src; System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(filename1)); System.Drawing.Image newimage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppRGB); Graphics g = Graphics.FromImage(newimage); g.DrawImage(image,0,0,image.Width,image.Height); Font f = new Font(FontType.SelectedItem.Text, Int32.Parse(FontSize.SelectedItem.Text)); Brush b = new SolidBrush(Color.Red); g.DrawString(Caption.Text, f, b, 10, 140); g.Dispose(); System.Drawing.Image thumbImage = newimage.GetThumbnailImage(Int32.Parse(Width.Text),Int32.Parse(Height.Text),null,0); image.Dispose(); thumbImage.Save(Server.MapPath(filename1), ImageFormat.JPEG); Image1.Src=filename1; Caption.Text=""; } </script> <body> <asp:label id="dis" runat=server/> <form enctype="multipart/form-data" runat=server> <h3> Select File To Upload: <input id="UploadFile" type=file runat=server> <asp:button Text="Upload Me!" OnClick="UploadBtn_Click" runat=server/> <hr> <asp:panel id="ImageEditor" Visible=false runat=server> <img ID="Image1" src="" runat="server"/> <h3> Image Width: <asp:textbox id="Width" runat=server/> Image Height: <asp:textbox id="Height" runat=server/> <br/> Text Caption: <asp:textbox id="Caption" runat=server/> Caption Size: <asp:dropdownlist id="FontSize" runat=server> <asp:listitem>14</asp:listitem> <asp:listitem>18</asp:listitem> <asp:listitem>26</asp:listitem> <asp:listitem>36</asp:listitem> <asp:listitem>48</asp:listitem> <asp:listitem>62</asp:listitem> </asp:dropdownlist> Caption Font: <asp:dropdownlist id="FontType" runat=server> <asp:listitem>黑体</asp:listitem> <asp:listitem>仿宋</asp:listitem> <asp:listitem>隶书</asp:listitem> <asp:listitem>楷书</asp:listitem> <asp:listitem>方正姚体</asp:listitem> <asp:listitem>华文彩云</asp:listitem> </asp:dropdownlist> <asp:button Text="Update Image" OnClick="UpdateBtn_Click" runat=server/> </h3> </asp:panel> </form> </body></html> http://www.cnblogs.com/index/archive/2004/10/20/54498.aspx www.wave12.com缩略图水印组件wsImage3.5 http://blog.csdn.net/greennetboy/archive/2005/12/17/554465.aspx 帮帮忙我难住了 CheckBoxList1 订单主从表录入设计思路,越简单越好 高手来看看! asp.net 关于设置文本框焦点的问题? c# 动态转静态的问题 asp.net程序放置问题 怎么做的网页跳转,使地址栏的链接地址是不变的 asp.net如何美工 类应用的问题! 那位大侠有ASP.NET的ubb函数,很有用啊? 已有相关代码,时间问题求解 在ASP.Net导航栏里的链接是动态的生成的吗?
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<html>
<script runat =server>
void UploadBtn_Click(Object sender, EventArgs e) {
String filename;
String filename1;
String[] filename2;
int q;
filename=UploadFile.PostedFile.FileName ;
filename2=filename.Split(new Char[] {'\\'});
q=filename2.GetUpperBound(0);
filename1=filename2[q];
dis.Text="上传文件名:"+filename1+"<br/>";
UploadFile.PostedFile.SaveAs(Server.MapPath(filename1));
ImageEditor.Visible = true;
dis.Text+="文件大小:"+UploadFile.PostedFile.ContentLength+"字节数";
Image1.Src=filename1;
}
void UpdateBtn_Click(Object sender, EventArgs e) {
String filename1;
filename1=Image1.Src;
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(filename1));
System.Drawing.Image newimage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppRGB);
Graphics g = Graphics.FromImage(newimage);
g.DrawImage(image,0,0,image.Width,image.Height);
Font f = new Font(FontType.SelectedItem.Text, Int32.Parse(FontSize.SelectedItem.Text));
Brush b = new SolidBrush(Color.Red);
g.DrawString(Caption.Text, f, b, 10, 140);
g.Dispose();
System.Drawing.Image thumbImage = newimage.GetThumbnailImage(Int32.Parse(Width.Text),Int32.Parse(Height.Text),null,0);
image.Dispose();
thumbImage.Save(Server.MapPath(filename1), ImageFormat.JPEG);
Image1.Src=filename1;
Caption.Text="";
} </script> <body>
<asp:label id="dis" runat=server/>
<form enctype="multipart/form-data" runat=server> <h3> Select File To Upload: <input id="UploadFile" type=file runat=server> <asp:button Text="Upload Me!" OnClick="UploadBtn_Click" runat=server/> <hr>
<asp:panel id="ImageEditor" Visible=false runat=server> <img ID="Image1" src="" runat="server"/> <h3>
Image Width: <asp:textbox id="Width" runat=server/> Image Height: <asp:textbox id="Height" runat=server/> <br/> Text Caption: <asp:textbox id="Caption" runat=server/> Caption Size: <asp:dropdownlist id="FontSize" runat=server>
<asp:listitem>14</asp:listitem>
<asp:listitem>18</asp:listitem>
<asp:listitem>26</asp:listitem>
<asp:listitem>36</asp:listitem>
<asp:listitem>48</asp:listitem>
<asp:listitem>62</asp:listitem>
</asp:dropdownlist>
Caption Font: <asp:dropdownlist id="FontType" runat=server>
<asp:listitem>黑体</asp:listitem>
<asp:listitem>仿宋</asp:listitem>
<asp:listitem>隶书</asp:listitem>
<asp:listitem>楷书</asp:listitem>
<asp:listitem>方正姚体</asp:listitem>
<asp:listitem>华文彩云</asp:listitem>
</asp:dropdownlist>
<asp:button Text="Update Image" OnClick="UpdateBtn_Click" runat=server/> </h3>
</asp:panel> </form> </body>
</html>