您现在的位置: ASP技术网 >> ASP学习 >> ASP应用 >> 文章正文

  没有公告

推荐文章
固顶文章在ASP中使用SQL语句之12:连接
推荐文章二级域名原理以及程序,申请即可
固顶文章十天学会ASP之第四天
固顶文章十天学会ASP之第三天
固顶文章十天学会ASP之第二天
热门文章
在ASP中使用SQL
十天学会ASP之第
十天学会ASP之第
十天学会ASP之第
专题栏目
ASP上传图片文件,生成缩略图,并写上版权信息
作者:snow 文章来源:snow 点击数: 更新时间:2004-9-16
private void Button1_Click(object sender, System.EventArgs e)
{
if(File1.PostedFile.FileName!=null)
{
string namestr = Path.GetFileName(File1.PostedFile.FileName);//提取文件名
File1.PostedFile.SaveAs(Server.MapPath(".")+@"\"+namestr);
Image2.Visible=true;
Image2.ImageUrl=Server.MapPath(".")+@"\"+namestr;
System.Drawing.Image image,aNewImage;
image=System.Drawing.Image.FromStream(File1.PostedFile.InputStream);
decimal width=image.Width;
decimal height=image.Height;
int newwidth,newheight;
if(width>height)
{
newwidth=150;
newheight=(int)(height/width*150);
}
else
{
newheight=150;
newwidth=(int)(width/height*150);
}
aNewImage=image.GetThumbnailImage(newwidth,newheight,null,IntPtr.Zero);
Bitmap output=new Bitmap(aNewImage);
Graphics g=Graphics.FromImage(output);
g.DrawString(TextBox1.Text.Trim(),new Font("Courier New", 9),new SolidBrush(Color.Red),60,60);//写版权信息及文本格式及位置
output.Save(Server.MapPath(".")+@"\s_"+namestr,System.Drawing.Imaging.ImageFormat.Jpeg);
Image1.Visible=true;
Image1.ImageUrl=Server.MapPath(".")+@"\s_"+namestr;
}
}

发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!) 去论坛聊聊
    站内文章搜索
    点击申请点击申请点击申请点击申请点击申请点击申请点击申请点击申请