Reputation: 29
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.
Upvotes: 2
Views: 6202
Reputation: 10722
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.
Upvotes: 5
Reputation: 33406
What you're asking for is impossible. Scaling a raster image where new resolution > native resolution
is by definition lossy. If by any chance I misunderstood the question, I apologize in advance.
Upvotes: 2