Is there any way or external library that can resize image using Lanczos (ideally) or at least bicubic alg. under Android? (faster is better of course, but quality is priority, a processing time is secondary)
Everything what I've got so far is this:
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, newWidth, newHeight, true);
However it uses bilinear filter and the output quality is terrible. Especially if you want to preserve details (like thin lines or readable texts).
There are many good libraries for Java as discussed for example here: Java - resize image without losing quality
However it's always depended on Java awt classes like java.awt.image.BufferedImage
, so it can't be used in Android.
Is there a way how to change the default (bilinear) filter in Bitmap.createScaledBitmap()
method or some library like Morten Nobel's lib that is able to work with android.graphics.Bitmap
class (or with some raw representation, as @Tron in the comment has pointed out)?
The most promising IMO is to use libswscale (from FFmpeg), it offers Lanczos and many other filters. To access
Bitmap
buffer from native code you can use jnigraphics. This approach guarantees nice performance and reliable results.EDIT
Here you can find rough demo app, that uses proposed approach. At the moment performance is frustratingly bad, so it should be investigated to decide if we to do something to improve it.