欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【如何在上传的图片上打自己的文字水印】,下面是详细的分享!
如何在上传的图片上打自己的文字水印
<%@PageLanguage="c#"Debug="true"Trace="true"%>
<%@ImportNamespace="System.IO"%>
<%@ImportNamespace="System.Drawing"%>
<%@ImportNamespace="System.Drawing.Imaging"%>
<html>
<scriptrunat=server>
voidUploadBtn_Click(Objectsender,EventArgse){
Stringfilename;
Stringfilename1;
String[]filename2;
intq;
filename=UploadFile.PostedFile.FileName;
filename2=filename.Split(newChar[]{'\\'});
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;
}
voidUpdateBtn_Click(Objectsender,EventArgse){
Stringfilename1;
filename1=Image1.Src;
System.Drawing.Imageimage=System.Drawing.Image.FromFile(Server.MapPath(filename1));
System.Drawing.Imagenewimage=newBitmap(image.Width,image.Height,PixelFormat.Format32bppRGB);
Graphicsg=Graphics.FromImage(newimage);
g.DrawImage(image,0,0,image.Width,image.Height);
Fontf=newFont(FontType.SelectedItem.Text,Int32.Parse(FontSize.SelectedItem.Text));
Brushb=newSolidBrush(Color.Red);
g.DrawString(Caption.Text,f,b,10,140);
g.Dispose();
System.Drawing.ImagethumbImage=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:labelid="dis"runat=server/>
<formenctype="multipart/form-data"runat=server>
选择上传文件:<inputid="UploadFile"type=filerunat=server>
<asp:buttonText="UploadMe!"OnClick="UploadBtn_Click"runat=server/>
<hr>
<asp:panelid="ImageEditor"Visible=falserunat=server>
<imgID="Image1"src=http://www.chinaz.com/program/2008/0911/""runat="server"/>
图像宽度:<asp:textboxid="Width"runat=server/>
图像高度:<asp:textboxid="Height"runat=server/><br>
文本标题:<asp:textboxid="Caption"runat=server/>
标题字号:<asp:dropdownlistid="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>
标题字体:<asp:dropdownlistid="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:buttonText="UpdateImage"OnClick="UpdateBtn_Click"runat=server/>
</asp:panel>
</form>
</body>
</html>
以上所分享的是关于如何在上传的图片上打自己的文字水印,下面是编辑为你推荐的有价值的用户互动:
相关问题:word中怎样给图片添加文字水印
答:一、word2003添加水印 点击菜单栏的“格式”——“背景”——“水颖,弹出“水颖设置窗口,先选择水印类型。 二、word2007添加水印 word2007是点击菜单栏上面的“页面布局---水颖,然后在水印的下拉框上面选择“自定义”即可弹出添加水印的对话框,就可以在上... >>详细
相关问题:如何在图片上添加水印文字
答:工作中,在打印一些重要文件时给文档加上水印,例如“绝密”、“保密”的字样,可以让获得文件的人都知道该文档的重要性。Word2003具有添加文字和图片两种类型水印的功能,水印将显示在打印文档文字的下面,它是可视的,但不会影响文字的显示效果。 ... >>详细
相关问题:如何在word文档(包括文字及图片)里添加水印
答:1、打开一个需要添加水印的Word文档; 2、点击页面布局,水印; 3、点击“自定义水颖,就可以添加文字水印; 4、点图片水印,选择图片; 5、击应用后图片水印就生成了,图片的大小也可以根据需要选择; 6、图片水印的效果,可以选择冲蚀,这样就... >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
