/// <summary>
/// 图像质量提升 解决打印模糊问题
/// </summary>
/// <param name="sourceimg"></param>
/// <param name="dpiX"></param>
/// <param name="dpiy"></param>
/// <returns></returns>
static public Bitmap ImageQualityUp(System.Drawing.Image sourceimg, float dpiX, float dpiy)
{
// 创建画布
int dstWidth = sourceimg.Width * 2;
int dstHeight = sourceimg.Height * 2;
Bitmap bmp = new Bitmap(dstWidth, dstHeight, System.Drawing.Imaging.PixelFormat.Format64bppArgb);
bmp.SetResolution(dpiX, dpiy);
using (Graphics g = Graphics.FromImage(bmp))
{
// 用白色清空
g.Clear(System.Drawing.Color.White);
// 指定高质量的双三次插值法。执行预筛选以确保高质量的收缩。此模式可产生质量最高的转换图像。
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
// 指定高质量、低速度呈现。
g.SmoothingMode = SmoothingMode.HighQuality;
// 在指定位置并且按指定大小绘制指定的 Image 的指定部分。
g.DrawImage(sourceimg, new Rectangle(0, 0, dstWidth, dstHeight),
new Rectangle(0, 0, sourceimg.Width, sourceimg.Height), GraphicsUnit.Pixel);
}
return bmp;
}
参考网上的代码,具体哪里忘记了