如何在上传的图片上写字
来源:互联网 发布:无权限访问网络打印机 编辑:程序博客网 时间:2024/04/28 19:49
<%@ 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>
选择上传文件: <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"/>
图像宽度: <asp:textbox id="Width" runat=server/>
图像高度: <asp:textbox id="Height" runat=server/> <br>
文本标题: <asp:textbox id="Caption" runat=server/>
标题字号: <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>
标题字体: <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/>
</asp:panel>
</form>
</body>
</html>
- 如何在上传的图片上写字
- 如何在上传的图片上写字
- 如何在上传的图片上写字
- 一个实现图片上传/产生缩略图/在上传图片上写字功能的完整页面代码
- 在图片上写字
- 一个在图片上写字的方法
- hchxxzx--》一个实现图片上传/产生缩略图/在上传图片上写字功能的完整页面代码
- 如何在图片里写字
- winform中在图片上写字
- 在图片上写字 (C#)
- 利用php在图片上写字(中英文)
- 在一个图片上写字并保存
- matlab在图片上写字后保存
- 如何在图上写字,或者画画。
- 用canvas画的图片跟在图片上写字居中的问题?
- c#图片上写字
- 图片上写字
- Android画圆角矩形图片,并在图片上写字
- ASP.NET中使用数据处理插入数据注意的问题
- 如何取得IP/用户名等信息
- ASP.NET热点问题解答14个
- ASP.NET中如何防范SQL注入式攻击
- 原创的自定义分页UserControl分享及探讨
- 如何在上传的图片上写字
- 在ASP.NET程序中创建唯一序号
- 通过探测邮件服务器进行Email地址有效性检验
- 用ASP.Net(C#)连接Oracle数据库的方法
- ASP.NET创建Web服务之设计方针
- asp.net2.0中一次性更新所有GRIDVIEW的记录
- 保存图片流到数据库之后固定显示新法
- 一个功能齐全的DataGrid分页例子
- ASP.net组件编程中的两种事件编写方法