java设置图片质量,如何使用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.

Thank You,

GaneshKumar.

解决方案

Ganesh,

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);

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.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值