Android的:比使用双线性重采样更好的算法位图大小调整(如Lanczos3) [英] Android: Bitmap resizing using better resampling algorithm than bilinear (like Lanczos3)

查看:1523
本文介绍了Android的:比使用双线性重采样更好的算法位图大小调整(如Lanczos3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法或外部库,可以使用兰克泽斯(理想情况下)或者至少是双三次ALG调整图像。在 Android版? (快当然好,但质量优先,处理时间是次要的)

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

不过它使用双线性过滤器和输出质量是可怕的。特别是如果你想preserve细节(如细线或可读的文本)。

However it uses bilinear filter and the output quality is terrible. Especially if you want to preserve details (like thin lines or readable texts).

有作为例如这里所讨论的Java许多好的库:
爪哇 - 调整图像不失去质量

There are many good libraries for Java as discussed for example here: Java - resize image without losing quality

但它总是依赖于Java的AWT类,如 java.awt.image.BufferedImage中的,所以它不能在Android中使用。

However it's always depended on Java awt classes like java.awt.image.BufferedImage, so it can't be used in Android.

有没有办法如何更改默认的(双线)在 Bitmap.createScaledBitmap)过滤器(法或类似的莫滕诺贝尔的lib ,能够与 android.graphics.Bitmap 类(或者与一些生再presentation,如@Tron在注释中指出)?

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

推荐答案

最有前途的国际海事组织是使用的 libswscale (从FFmpeg的),它提供了兰克泽斯和许多其他过滤器。访问位图从本地$ C $缓冲液C可以使用的 jnigraphics 的。这种做法保证了不错的性能和可靠的结果。

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.

修改

这里你可以找到粗糙的演示程序,使用建议的方法。目前的表现令人沮丧的是不好的,所以应该进行调查,以决定是否我们做一些事来改善它。

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.

这篇关于Android的:比使用双线性重采样更好的算法位图大小调整(如Lanczos3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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