如何使用Java调整图像大小而不损失质量? [英] How to resize a image without losing quality using java?

查看:372
本文介绍了如何使用Java调整图像大小而不损失质量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是:如何在不损失画质的情况下调整图像的大小".

My requirement is:"How to resize the image without loosing quality using swing".

我正在使用缩放器组件,标签,面板. 我正在使用调整大小的概念,此时图像变得模糊并且失去了质量. 所以您知道吗如何使用摆动概念在不损失画质的情况下调整图像大小?".向我发送相关信息或代码.

I am using resizer components,label,panel. I am using resizing concept at this time image is blurring and lose the quality. so any one do you know "how to resize the image without loosing the quality using swing concept?". Send me the related information or code.

谢谢, GaneshKumar.

Thank You, GaneshKumar.

推荐答案

Ganesh,

您可以查看 imgscalr ,这是一个非常简单的(使用单个类,一堆静态方法),看起来像这样使用:

You might take a look at imgscalr, it is an extremely simple (single class, bunch of static methods to use) that looks like this to use:

BufferedImage thumbnail = Scalr.resize(srcImage, 150);

要确保获得最高质量的缩放结果,可以将其他参数传递给resize方法,如下所示:

To ensure the highest-quality scaled result, you can pass additional arguments to the resize method like so:

BufferedImage thumbnail = resize(img, Method.ULTRA_QUALITY, 125, OP_ANTIALIAS);

还有一系列简单的图像操作(例如裁剪,填充,旋转等),您也可以使用.还有一个异步类,该类可以一次将许多操作排队,并在例如要在服务器上进行图像处理的情况下在可配置数量的线程中执行它们.

There are also a slew of simple image operations (like cropping, padding, rotating, etc.) that you can use as well. There is also an asynchronous class that can queue up many operations at once and execute them in a configurable number of threads if you are doing image processing on a server for example.

该库是用纯Java编写的,并根据Apache 2许可发布,您可以在此处找到所有源代码. (如果您有兴趣).

The library is written in pure Java and released under the Apache 2 license, you can find all the source code here if you are interested.

如果您对其他示例或用例感到好奇,则这里有其他与之相关的问题.

Here are some other SO questions related to it if you are curious about other examples or use-cases.

这篇关于如何使用Java调整图像大小而不损失质量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆