SWT:如何进行高质量图像调整大小
我的应用程序需要调整 ImageData 的大小。不幸的是,我还没有通过 GC(开启抗锯齿和高插值)或 ImageData.scaledTo() 获得我想要的结果。生成的图像质量太低,无法接受。进行高质量 ImageData 调整大小的最佳方法是什么?
编辑: 我正在缩小规模。
My application needs to resize ImageData. Unfortunately, I haven't gotten the results I want with GC (with antialias on and interpolation on high), or ImageData.scaledTo(). The resulting image is of too low a quality to be acceptable. What's the best way to do a high quality ImageData resize?
Edit: I'm scaling down.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
AWT 提供不同模式的图像缩放。对于缩小比例,面积平均可提供最佳质量。当然,可以重新实现 SWT 的面积平均缩放算法,或者,对于通常就足够的快速解决方案:
代码为SWT 和 AWT 图像之间的转换可以在此处找到。
AWT offers image scaling with different modes. For downscaling, Area Averaging offers the best quality. One could of course re-implement the area averaging scaling algorithm for SWT, or, for a quick solution which often suffices:
The code to convert between SWT and AWT images can be found here.
公认的解决方案不涉及透明度。这是我遇到的一个片段,它可以进行高质量的调整大小并保留透明度:
我在这里找到了它:
http://aniszczyk.org/2007/08/09/resizing-images-using-swt/
The accepted solution doesn't deal with transparency. Here's a snippet I've came across that does hi-quality resize and preserves transparency as well:
I've found it here:
http://aniszczyk.org/2007/08/09/resizing-images-using-swt/
我们在 ImageMagick / JMagick 方面取得了成功。 http://www.jmagick.org/index.html
唯一的问题是,如果图像都是用户上传的,而且你的用户基数很大,你就会因为无效的图片文件等等而出现内存泄漏。
We've had success with ImageMagick / JMagick. http://www.jmagick.org/index.html
The only problem is that if the images are user uploads, and you have a large user base, you will have memory leaks because of invalid image files and so on.