打印前我需要自己缩放图片吗?
一个简单的问题 - 如果我想打印一张图片,使其最适合 C# 中的页面,我是否必须自己将其缩放到页面的尺寸?
我注意到关于如何扩展的很多好的答案,我只想知道如果我需要缩放自己,因为缩放不是图像处理的一部分,它只是为了打印。
(一个简单的“是”(如果这是答案)就可以了)
编辑: 目前我正在使用以下方法进行缩放:
e.Graphics.DrawImage(my_image, destRect, srcRect, GraphicsUnit.Pixel);
虽然 destRect 是所需输出尺寸的矩形,但我已经完成了一个简单的算法来将此 destRect 设置为最佳尺寸,同时保留原始的纵横比。 (顺便说一句,我对这种简单的缩放不满意,因为它缺乏图像质量,如果我必须的话,可能会更新为更奇特的东西)。
但我想知道框架是否提供了一些用于打印目的的自动缩放功能,我真的不想重新发明这个轮子。
A simple question - If I want to print a picture so it best fits the page in C#, do I have to scale it to the dimensions of the page myself ?
I've noticed the many good answers about how-to scale, I just want to know If I need to scale myself, as the scaling isn't a part of an image processing, it's only for the sake of the printing.
(a simple yes (if it's the answer) would do)
Edit:
Currently I'm scaling using:
e.Graphics.DrawImage(my_image, destRect, srcRect, GraphicsUnit.Pixel);
Whereas destRect is a rectangle of the dimensions of the wanted output, I've done a simple algorithm to set this destRect to optimal sizes while preserving the original aspect ratio. (btw I'm not happy with this simple scaling, as it lacks in Image quality, will probably update to something fancier if I must).
But I've wanted to know if there's some auto-scaling provided by the framework for printing purposes, I really don't want to re-invent this wheel..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是否像是/否那么简单。我怀疑您仍然必须使用 GDI+ 和 Graphics 对象,因此缩放就像在打印设备的图形对象上调用 Graphics.DrawImage(...) 一样简单。不过,某些打印机驱动程序可能支持自动缩放源。
I'm not sure if this is as simple as yes/no. I suspect that you must still use GDI+ and the
Graphics
object, so scaling is as simple as callingGraphics.DrawImage(...)
on the graphics object for the printing device. Some printer drivers might support scaling the source automatically, though.