我正在处理PrintPageEventHandler
,PrintDocument
以便使用该方法将图像绘制到Graphics
设备上。Image.FromFile
我尝试将 dpi 值设置为 600,并且
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality
正如这里所建议的,但与使用例如 Windows Photo Viewer 打印相同的文件相比,打印的图像看起来仍然像素化且粗糙,这提供了出色的结果(在 Windows 7 上测试)。
我注意到 Paint.net 使用 WIA 打印对话框 - 这是否意味着图像质量是 .NET 的限制,还是我做错了?
完整的方法在这里:
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
// Draw a picture.
ev.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
ev.Graphics.SmoothingMode = SmoothingMode.HighQuality;
ev.Graphics.CompositingQuality = CompositingQuality.HighQuality;
ev.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
ev.Graphics.DrawImage(Image.FromFile(Global.APPDATA_PATH+ @"tmp\print.png"), ev.Graphics.VisibleClipBounds);
// Indicate that this is the last page to print.
ev.HasMorePages = false;
}