All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
LINQ体验(17)——LINQ,to,SQL语句之动态查询_[Asp.Net教程]
Silverlight,2,(beta1)数据操作(6)——使用LINQ,to,SQL进行数据_[Asp.Net教程]
delphi设置提示信息
利用正则表达式自动给Email地址和Url加上连接_[Asp.Net教程]
PHP程序中的特效应用,实用珍藏代码举例_php资料_编程技术
网页HTML教程:建立有亲和力的超级连接_[Html教程]
C#,3.0新特性初步研究,Part2:使用扩展方法_[Asp.Net教程]
效果不错的PHP分页类代码_[PHP教程]
Visual C++ 6.0教程:c++数据类型之数组
HTML语言剖析(一)Html简介_[Html教程]
Reading number is top 10 pictures
Plump, too plump!2
囚犯暴乱了咋办?
Terrorist smile the largest human history an explosion1
移民小国也实惠2
王艳写真温柔如水2
人美胸美腿更美3
A man's favorite things8
传几朵花
Sexy women in 2013--2
Household design comfortable contracted
Download software ranking
Professional killers2 for Android
Tram sex maniac 2 (H) rar bag18
Tram sex maniac 2 (H) rar bag2
Boxer vs Yellow3
Tram sex maniac 2 (H) rar bag3
C#COM编程指南
C++教程第四版
Boxer vs Yellow2
WebService在.NET中的实战应用教学视频 → 第5集
Proficient in JavaScript
delv published in(发表于) 2014/1/16 9:29:11 Edit(编辑)
asp.net生成缩略图及给原始图加水印_[Asp.Net教程]

asp.net生成缩略图及给原始图加水印_[Asp.Net教程]

asp.net生成缩略图及给原始图加水印_[Asp.Net教程]

ASP.net生成缩略图及给原始图加水印,代码如下:


  using System.IO;
  using System.Drawing.Imaging;
  private void Button1_ServerClick(object sender, System.EventArgs e)
  {
  Graphics g=null;
  System.Drawing.Image upimage=null;
  System.Drawing.Image thumimg=null;
  System.Drawing.Image simage=null;
  Bitmap outputfile=null;
  try
  {
  string extension = Path.GetExtension(File1.PostedFile.FileName).ToUpper();
  string filename = DateTime.Now.ToString("yyyyMMddhhmmss");
  string smallpath = Server.MapPath(".")+"/smallimg/";
  string bigpath = Server.MapPath(".")+"/bigimg/";
  int width,height,newwidth,newheight;
  System.Drawing.Image.GetThumbnailImageAbort callb =new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
  if(!Directory.Exists(smallpath))
  Directory.CreateDirectory(smallpath);
  if(!Directory.Exists(bigpath))
  Directory.CreateDirectory(bigpath);
  Stream upimgfile = File1.PostedFile.InputStream;
  string simagefile = Server.MapPath("a8logo.jpg"); //要加水印的文件
  simage=System.Drawing.Image.FromFile(simagefile);
  upimage= System.Drawing.Image.FromStream(upimgfile); //上传的图片
  width = upimage.Width;
  height = upimage.Height;
  if(width>height)
  {
  newwidth=200;
  newheight =(int)((double)height/(double)width * (double)newwidth);
  }
  else
  {
  newheight=200;
  newwidth=(int)((double)width/(double)height * (double)newheight);
  }
  thumimg = upimage.GetThumbnailImage(newwidth,newheight,callb,IntPtr.Zero);
  outputfile=new Bitmap(upimage);
  g=Graphics.FromImage(outputfile);
  g.DrawImage(simage,new Rectangle(upimage.Width-simage.Width,upimage.Height-simage.Height,upimage.Width,upimage.Height),0,0,upimage.Width,upimage.Height,GraphicsUnit.Pixel);
  string newpath = bigpath + filename + extension; //原始图路径
  string thumpath = smallpath + filename + extension; //缩略图路径
  outputfile.Save(newpath);
  thumimg.Save(thumpath);
  outputfile.Dispose();
  }
  catch(Exception ex)
  {
  throw ex;
  }
  finally
  {
  if(g!=null)
  g.Dispose();
  if(thumimg!=null)
  thumimg.Dispose();
  if(upimage!=null)
  upimage.Dispose();
  if(simage!=null)
  simage.Dispose();
  }
  }
  public bool ThumbnailCallback()
  {
  return false;
  }


来源:网络







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.