日期:2014-05-17  浏览次数:21020 次

C#给图片加水印文字后整个图片质量下降
我在ASP.NET中动态给JPG图片加水印 文字,这个目标已经实现,但是保存之后发现,加了水印的图片对比原图片模糊很多,本来的图片层次分明,很漂亮,加了水印后只能用凑合来形容,虽然能看清,但是不能满足视觉需要。

网上找了很多资料,大部分都是说怎么保证缩略图的质量,可我的图片处理前后大小没有改变,所以不存在缩略图

相信肯定有让图片处理后质量不下降 的高招,恳请大虾们赐教!!谢谢!

目标:C#处理JPG图片前后,保持图片质量不降低[size=16px][/size]

------解决方案--------------------
C#图片水印类 
using System; 
using System.Collections.Generic; 
using System.Text; 
using System.Drawing; 
using System.IO; 
using System.Drawing.Drawing2D; 
using System.Drawing.Imaging; 
namespace ECHX.BLL 

/// <summary> 
/// WaterMark 的摘要说明 
/// </summary> 
/// 
/// <param name="strCopyright">要加入的文字 </param> 
/// <param name="strMarkPath">水印图片路径 </param> 
/// <param name="strPhotoPath">要加水印的图片路径 </param> 
/// <param name="strSavePath">处理后的图片路径 </param> 
/// <param name="iMarkRightSpace">水印在修改图片中距左边的宽度 </param> 
/// <param name="iMarkButtomSpace">水印在修改图片中距底部的高度 </param> 
/// <param name="iDiaphaneity">水印图片的透明度 </param> 
/// <param name="iFontRightSpace">文字 </param> 
/// <param name="iFontButtomSpace">文字 </param> 
/// <param name="iFontDiaphaneity">文字 </param> 
/// <param name="bShowCopyright">是否显示文字 </param> 
/// <param name="bShowMarkImage">是否显示水印图片 </param> 

public class WaterMark 

#region param 
private string strCopyright,strMarkPath,strPhotoPath,strSavePath; 
private int iMarkRightSpace, iMarkButtomSpace, iDiaphaneity; 
private int iFontRightSpace = 0, iFontButtomSpace = 0, iFontDiaphaneity=80; 
private int iFontSize = 10; 
private bool bShowCopyright=true, bShowMarkImage=true; 
#endregion 

#region WaterMark 
public WaterMark() 

this.strCopyright = ""; 
this.strMarkPath = null; 
this.strPhotoPath = null; 
this.strSavePath = null; 
this.iDiaphaneity = 70; 
this.iMarkRightSpace = 0; 
this.iMarkButtomSpace = 0; 


/// <summary> 
/// 主要用两样都加的 
/// </summary> 
public WaterMark(string copyright,string markPath,string photoPath,string savePath) 

this.strCopyright = copyright; 
this.strMarkPath = markPath; 
this.strPhotoPath = photoPath; 
this.strSavePath = savePath; 
this.iDiaphaneity = 70; 
this.iMarkRightSpace = 0; 
this.iMarkButtomSpace = 0; 

#endregion 

#region property 

/// <summary> 
/// 设置是否显示水印文字 
/// </summary> 
public bool ShowCopyright 

set { this.bShowCopyright = value; } 


/// <summary> 
/// 设置是否显示水印图片 
/// </summary> 
public bool ShowMarkImage