如何在 .NET 中处理图像以实现像 Windows 照片库一样的质量的整页打印?

发布于 2024-08-04 21:07:08 字数 524 浏览 9 评论 0原文

我正在 C# 中编写打印路由,使用 .NET PrintDocument 类,处理 OnPrintPage 事件。

我已设法最大化边距并以横向模式打印图像,但是它看起来根本不如从 Windows 照片库打印相同的图像文件(以前称为 Windows 图片和传真查看器) ),Windows Vista 中的默认图像预览程序。

我注意到那里有一个选项可以选择“锐化图像以进行打印”,但是它有什么作用呢?

我曾考虑过首先从 Windows 照片库打印图像的副本,然后再次通过打印机发送纸张以打印我需要的自定义叠加层,但每次都很难使其对齐,因为打印机会吸收工作表没有达到我需要的精度...所以我真的需要在 C# 中执行所有绘图命令,包括图像。

有谁知道如何对位图进行预处理,使其打印效果与 Windows 照片库一样好? 是否有任何简单的打印驱动程序可以将照片库打印输出截取为标准图像文件(bmp、png 等)可以被 .NET Image 类读取吗?我在这里完全支持创造力。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

A君 2024-08-11 21:07:09

Paint.Net 使用 Windows 图片和传真查看器进行打印,并且它以前是开源的。

快速谷歌搜索“Paint.Net 来源”似乎会找到它,尽管是在他们再次关闭它之前的早期版本。我会查看他们的来源并看看他们如何调用对话框

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

沫雨熙 2024-08-11 21:07:09

如果您尝试拍摄小图像并打印它的大版本,那么在内存中创建图像的较大版本然后打印该较大版本可能会有所帮助。通常您会这样做:

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

基本上您将让 GDI+ 而不是打印机来调整图像大小;这可能是也可能不是一种改进。照片库中的“锐化”当然比这更复杂,并且针对打印问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文