oad1.PostedFile.InputStream);
img.ReducedImage(0.4, serverpath2);//0.4表示缩小40%
this.lb_info.Text = "上传成功!";
}
}
catch (Exception error)
{
this.lb_info.Text = "上传发生错误!原因:" + error.ToString();
}
}
}
8.上传图片加水印(文字水印,图片水印,文字+图片水印)
效果图:
原图
水印
给图片加水印以后(注意右上角+正下方)
代码:
DrawImg.cs 出自http://www.codeproject.com/csharp/watermark.asp
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
public class DrawImg
{
private string WorkingDirectory = string.Empty ; //路径
private string ImageName = string.Empty; //被处理的图片
private string ImageWater = string.Empty; //水印图片
private string FontString = string.Empty; //水印文字
enum DealType{NONE,WaterImage,WaterFont,DoubleDo}; //枚举命令
private DealType dealtype;
public DrawImg()
{}
public string PublicWorkingDirectory
{
get
{
return WorkingDirectory;
}
set
{
WorkingDirectory = value;
}
}
public string PublicImageName
{
get
{
return ImageName;
}
set
{
ImageName =