阅读内容 

ASP上传图片文件,生成缩略图,并写上版权信息

[日期:2005-11-19] 来源:易书网  作者:佚名 [字体: ]
 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;
}
}
阅读:
录入:

推荐 】 【 打印
相关新闻      
本文评论       全部评论
  sb   (** ,2006-05-08 )
  连哪种语言都搞不清楚。。。   (12312313 ,2005-12-04 )
发表评论
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款


点评: 字数
姓名:
Advertisement
内容查询


Advertisement