How can I process an image in .NET for a full-page print with a quality like Windows Photo Gallery does it?

こ雲淡風輕ζ 提交于 2019-12-23 19:44:21

问题


I'm writing a printing routing in C#, using the .NET PrintDocument class, handling the OnPrintPage event.

I've managed to maximize the margins and print the Image in landscape mode, but it simply does not look as good as when I print the same image file from Windows Photo Gallery (formerly Windows Picture and Fax Viewer), the default image preview program in Windows Vista.

I noticed an option there for selecting "Sharpen Image for Printing", but what does that do?

I've thought about printing copies of the image from Windows Photo Gallery first, then sending the sheets through the printer a second time to print the custom overlays I need, but it's hard to make it line up every time, since the printer sucks the sheet in without the kind of precision I need... so I really need to do ALL the drawing commands within C#, including the image.

Does anyone know how to perform pre-processing on the bitmap so that it prints as nicely as Windows Photo Gallery does it? Are there any simple print drivers that can intercept Photo Gallery printing output as a standard image file (bmp, png, etc.) that can be read by the .NET Image class? I'm all for creativity here.


回答1:


Paint.Net uses the Windows Picture and Fax Viewer for its printing and it was previously open source.

A quick Google for "Paint.Net source" seems to turn it up, albeit in earlier incarnations before they closed it again. I'd look at their source and see how they invoke the dialog




回答2:


If you're trying to take a small image and print a large version of it, it might help to create a larger version of your image in memory and then print that larger version. This is generally how you would do this:

Bitmap largeBitmap = new Bitmap(800, 600);
using (Graphics g = Graphics.FromImage(largeBitmap))
{
    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
    g.DrawImage(smallImage ...) // I forget which of the 30 
        // overloads you need here
}
// then print largeBitmap

Basically you'd be letting GDI+ resize the image instead of the printer; this may or may not be an improvement. The "sharpening" in Photo Gallery is certainly more sophisticated than this, and targeted at printing issues.



来源:https://stackoverflow.com/questions/1440396/how-can-i-process-an-image-in-net-for-a-full-page-print-with-a-quality-like-win

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!