在 ASP.Net 应用程序中调整 PNG 大小
我正在为我的 Asp.net 应用程序生成一些 PNG 图表。使用 PNG,我达到了网站所需的质量,但我还需要生成一份报告,因为我必须将图表大小从 897x651 调整为 216x161。我怎样才能在不损失太多质量的情况下实现这一目标。我已经尝试过:
- http://www.peterprovost.org/ blog/post/Resize-Image-in-C.aspx
- Image.GetThumbnailImage(….)
我对这两种方式都不太满意。请问有人可以帮助我吗?使用 PNGout,您可以将 bmp 转换为 png,而不会损失质量。但你无法调整大小
I´m generating some PNG Diagrams for my Asp.net application. With PNG I reach the quality I need on the Website, but I also need to generate a Report and there for I have to Resize my Diagrams from 897x651 to 216x161. How can I achieve this, without losing too much of quality. I have tried :
- http://www.peterprovost.org/blog/post/Resize-Image-in-C.aspx
- Image.GetThumbnailImage(….)
I´m not really happy with both ways. Please can someone help me? With PNGout you can convert bmp to png without losing quality. But you cannot resize
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,我在使用 System.Drawing 类调整内容大小时遇到了同样的问题。
Graphics 类(这也在您发布的链接中使用 http ://www.peterprovost.org/blog/post/Resize-Image-in-C.aspx)具有属性 SmoothingMode 和 InterpolationMode。我将它们设置为:
这大大提高了质量(尽管在大图像上会带来性能损失),但到目前为止我只尝试过 JPG。
老实说,我很快就在我的 ASP.NET 应用程序中抛弃了 System.Drawing 并使用了 imagemagick (http://www.imagemagick .org/)用于图形内容。
Actually, I had the same problem on resizing stuff using System.Drawing classes.
The Graphics class (this is also used in the link you posted http://www.peterprovost.org/blog/post/Resize-Image-in-C.aspx) has a property SmoothingMode and InterpolationMode. I set them to:
This increased the quality quite a lot (comes with a performance penalty on large images though), but I only tried it with JPGs so far.
To be honest, I soon dumped System.Drawing in my ASP.NET app and used imagemagick (http://www.imagemagick.org/) for graphics stuff.
不损失质量的绝对最佳方法(如果您生成原始图像)是再次从头开始生成图像,但尺寸较小。
否则,.NET 中内置的图像缩放功能足以处理 PNG 图像。 - 请参阅上面 Marek 评论中的链接。
The absolute best way to not lose quality (if you are generating the original images) is to generate the image from scratch again but with the smaller dimensions.
Otherwise built in image scaling in .NET is more than capable for PNG images. - See link in Marek's comment above.