急待解决:给已有图片添加:文字+logo图片的水印效果 给一个页面放一个image 怎么在上面添加:公司名称+公司logo的水印效果 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你制作个这样的image不就行了? 用DIV做一个层覆盖过上面,或者将你的图片设成DIV的背景 http://blog.csdn.net/groupliu/archive/2007/04/06/1554529.aspx我照着这个做,可以实现,你自己去看看吧 /**/ /// <summary> /// 在图片上增加文字水印 /// </summary> /// <param name="Path">原服务器图片路径</param> /// <param name="Path_sy">生成的带文字水印的图片路径</param> protected void AddWater(string Path, string Path_sy) { string addText = "51aspx.com"; System.Drawing.Image image = System.Drawing.Image.FromFile(Path); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image); g.DrawImage(image, 0, 0, image.Width, image.Height); System.Drawing.Font f = new System.Drawing.Font("Verdana", 60); System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Green); g.DrawString(addText, f, b, 35, 35); g.Dispose(); image.Save(Path_sy); image.Dispose(); } /**/ /// <summary> /// 在图片上生成图片水印 /// </summary> /// <param name="Path">原服务器图片路径</param> /// <param name="Path_syp">生成的带图片水印的图片路径</param> /// <param name="Path_sypf">水印图片路径</param> protected void AddWaterPic(string Path, string Path_syp, string Path_sypf) { System.Drawing.Image image = System.Drawing.Image.FromFile(Path); System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image); g.DrawImage(copyImage, new System.Drawing.Rectangle(image.Width - copyImage.Width, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel); g.Dispose(); image.Save(Path_syp); image.Dispose(); } protected void Button2_Click(object sender, EventArgs e) { //自动保存远程图片 WebClient client = new WebClient(); //备用Reg:<img.*?src=([\"\'])(http:\/\/.+\.(jpg|gif|bmp|bnp))\1.*?> Regex reg = new Regex("IMG[^>]*?src\\s*=\\s*(?:\"(?<1>[^\"]*)\"|'(?<1>[^\']*)')", RegexOptions.IgnoreCase); MatchCollection m = reg.Matches(TextBox1.Text); foreach (Match math in m) { string imgUrl = math.Groups[1].Value; //在原图片名称前加YYMMDD重名名并上传 Regex regName = new Regex(@"\w+.(?:jpg|gif|bmp|png)", RegexOptions.IgnoreCase); string strNewImgName = DateTime.Now.ToShortDateString().Replace("-", "") + regName.Match(imgUrl).ToString(); try { //保存图片 client.DownloadFile(imgUrl, Server.MapPath("ImgUpload/Auto/" + strNewImgName)); } catch { } finally { } client.Dispose(); } Response.Write("<script>alert('远程图片保存成功,保存路径为ImgUpload/auto')</script>"); } 静态图片简单,用Image类就可以了动态图片麻烦一些,像gif /// <summary> /// 在图片上增加文字水印 /// </summary> /// <param name="Path">原服务器图片路径</param> /// <param name="Path_sy">生成的带文字水印的图片路径</param> protected void AddWater(string Path, string Path_sy) { string addText = "123"; System.Drawing.Image image = System.Drawing.Image.FromFile(Path); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image); g.DrawImage(image, 0, 0, image.Width, image.Height); System.Drawing.Font f = new System.Drawing.Font("Verdana", 60); System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Green); g.DrawString(addText, f, b, 35, 35); g.Dispose(); image.Save(Path_sy); image.Dispose(); } /**/ /// <summary> /// 在图片上生成图片水印 /// </summary> /// <param name="Path">原服务器图片路径</param> /// <param name="Path_syp">生成的带图片水印的图片路径</param> /// <param name="Path_sypf">水印图片路径</param> protected void AddWaterPic(string Path, string Path_syp, string Path_sypf) { System.Drawing.Image image = System.Drawing.Image.FromFile(Path); System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image); g.DrawImage(copyImage, new System.Drawing.Rectangle(image.Width - copyImage.Width, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel); g.Dispose(); image.Save(Path_syp); image.Dispose(); } js判断验证码??? 点击Gridview的单元格,如何获取它的行号和列号? ASP.NET实现下载并更新下载次数。求教啊..谢谢各位大虾了 asp.net 报表FusionCharts动态创建XML问题 动态分页问题,请大家帮忙! 日程安排上日历如何加入阴历 有没有asp.net技术方面比较自信的??? 有關驗証控件的問題.哪位可以幫我呢? AJAX的问题 ASPX和ASP在同一站点下的参数共享问题 怎样动态更换皮肤 HTML页面和asp.net 页面问题
我照着这个做,可以实现,你自己去看看吧
/**/
/// <summary>
/// 在图片上增加文字水印
/// </summary>
/// <param name="Path">原服务器图片路径</param>
/// <param name="Path_sy">生成的带文字水印的图片路径</param>
protected void AddWater(string Path, string Path_sy)
{
string addText = "51aspx.com";
System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
g.DrawImage(image, 0, 0, image.Width, image.Height);
System.Drawing.Font f = new System.Drawing.Font("Verdana", 60);
System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Green); g.DrawString(addText, f, b, 35, 35);
g.Dispose(); image.Save(Path_sy);
image.Dispose();
} /**/
/// <summary>
/// 在图片上生成图片水印
/// </summary>
/// <param name="Path">原服务器图片路径</param>
/// <param name="Path_syp">生成的带图片水印的图片路径</param>
/// <param name="Path_sypf">水印图片路径</param>
protected void AddWaterPic(string Path, string Path_syp, string Path_sypf)
{
System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
g.DrawImage(copyImage, new System.Drawing.Rectangle(image.Width - copyImage.Width, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel);
g.Dispose(); image.Save(Path_syp);
image.Dispose();
} protected void Button2_Click(object sender, EventArgs e)
{
//自动保存远程图片
WebClient client = new WebClient();
//备用Reg:<img.*?src=([\"\'])(http:\/\/.+\.(jpg|gif|bmp|bnp))\1.*?>
Regex reg = new Regex("IMG[^>]*?src\\s*=\\s*(?:\"(?<1>[^\"]*)\"|'(?<1>[^\']*)')", RegexOptions.IgnoreCase);
MatchCollection m = reg.Matches(TextBox1.Text); foreach (Match math in m)
{
string imgUrl = math.Groups[1].Value; //在原图片名称前加YYMMDD重名名并上传 Regex regName = new Regex(@"\w+.(?:jpg|gif|bmp|png)", RegexOptions.IgnoreCase); string strNewImgName = DateTime.Now.ToShortDateString().Replace("-", "") + regName.Match(imgUrl).ToString(); try
{
//保存图片
client.DownloadFile(imgUrl, Server.MapPath("ImgUpload/Auto/" + strNewImgName)); }
catch
{
}
finally
{ } client.Dispose();
} Response.Write("<script>alert('远程图片保存成功,保存路径为ImgUpload/auto')</script>"); }
动态图片麻烦一些,像gif
/// <summary>
/// 在图片上增加文字水印
/// </summary>
/// <param name="Path">原服务器图片路径</param>
/// <param name="Path_sy">生成的带文字水印的图片路径</param>
protected void AddWater(string Path, string Path_sy)
{
string addText = "123";
System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
g.DrawImage(image, 0, 0, image.Width, image.Height);
System.Drawing.Font f = new System.Drawing.Font("Verdana", 60);
System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Green); g.DrawString(addText, f, b, 35, 35);
g.Dispose(); image.Save(Path_sy);
image.Dispose();
} /**/
/// <summary>
/// 在图片上生成图片水印
/// </summary>
/// <param name="Path">原服务器图片路径</param>
/// <param name="Path_syp">生成的带图片水印的图片路径</param>
/// <param name="Path_sypf">水印图片路径</param>
protected void AddWaterPic(string Path, string Path_syp, string Path_sypf)
{
System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
g.DrawImage(copyImage, new System.Drawing.Rectangle(image.Width - copyImage.Width, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel);
g.Dispose(); image.Save(Path_syp);
image.Dispose();
}