思路:核心 圖像轉換
1、修改圖像dpi值
2、使用高質量的雙三次插值法
3、指定高質量
C# Code 、如下:
/// <summary>
/// 圖像質量提升 解決打印模糊問題
/// </summary>
/// <param name="sourceimg"></param>
/// <param name="dpiX"></param>
/// <param name="dpiy"></param>
/// <returns></returns>
private Bitmap ImageQualityUp(Image sourceimg, float dpiX, float dpiy)
{
// 創建畫布
Bitmap bmp = new Bitmap(currentBitmap.Width, currentBitmap.Height, PixelFormat.Format24bppRgb);
bmp.SetResolution(dpiX, dpiy);
using (Graphics g = Graphics.FromImage(bmp))
{
// 用白色清空
g.Clear(Color.White);
// 指定高質量的雙三次插值法。執行預篩選以確保高質量的收縮。此模式可產生質量最高的轉換圖像。
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
// 指定高質量、低速度呈現。
g.SmoothingMode = SmoothingMode.HighQuality;
// 在指定位置並且按指定大小繪製指定的 Image 的指定部分。
g.DrawImage(currentBitmap, new Rectangle(0, 0, currentBitmap.Width, currentBitmap.Height),
new Rectangle(0, 0, currentBitmap.Width, currentBitmap.Height), GraphicsUnit.Pixel);
}
return bmp;
}