Java Android:创建高质量的缩略图

Java Android:创建高质量的缩略图,java,android,image,scale,Java,Android,Image,Scale,我很难为拍摄的图像创建高质量的缩略图。我知道在网上有很多代码片段和教程来创建缩略图。我试过了,但我的问题是我无法生成高质量的缩略图。输出总是像素化的。有什么建议吗,图书馆或链接?提前谢谢 但是它的质量也很低 public static Bitmap scaleBitmap(Bitmap bitmap, int wantedWidth, int wantedHeight) { Bitmap output = Bitmap.createBitmap(wantedWidth, wan

我很难为拍摄的图像创建高质量的缩略图。我知道在网上有很多代码片段和教程来创建缩略图。我试过了,但我的问题是我无法生成高质量的缩略图。输出总是像素化的。有什么建议吗,图书馆或链接?提前谢谢

但是它的质量也很低

 public static Bitmap scaleBitmap(Bitmap bitmap, int wantedWidth, int wantedHeight) {
        Bitmap output = Bitmap.createBitmap(wantedWidth, wantedHeight, Config.ARGB_8888);
        Canvas canvas = new Canvas(output);
        Matrix m = new Matrix();

        m.setScale((float) wantedWidth / bitmap.getWidth(), (float) wantedHeight / bitmap.getHeight());

        canvas.drawBitmap(bitmap, m, new Paint());

        return output;
    }
你试过这个吗

Bitmap src = Thumbnails.getThumbnail(getContentResolver(), ContentUris.parseId(sourceUri), Thumbnails.MINI_KIND, options);
试试这个

Bitmap ThumbImage =ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(imagePath),THUMBSIZE, THUMBSIZE);
此实用程序可从API_级别8获得。[来源]

使用库。简单如下:

import rapid.decoder.BitmapDecoder;
...
Bitmap bitmap = BitmapDecoder.from(getResources(), R.drawable.image)
                             .scale(width, height)
                             .useBuiltInDecoder(true)
                             .decode();

如果您希望缩小到50%以下并获得HQ结果,请不要忘记使用内置解码器。

您在哪个语言版本和哪个平台上开发?您是否正在开发一个为android浏览器提供内容的web应用程序?我在android中使用java。我有一个本地android应用程序,带有一个自定义摄像头,我想创建一个我拍摄的图像的缩略图。给我们看一些你尝试过的代码。我只能用android API定义漂亮的缩略图。@Snicolas,我发布了一些代码。请查收。:)您应该看看这个:。还有这个