简体   繁体   中英

Android: Creating a high quality thumbnail image

I have some difficulties creating a high quality thumbnail for my captured images. I understand that there are many snippet codes and tutorials in the web to create a thumbnail. I tried them and my problem is I can't produce a high quality thumbnail image. The output is always pixelated. Any suggestion ,library or links guys? thanks in advance.

I tried this one but its low quality also.

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

Use RapidDecoder library. It is simple as follow:

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

Don't forget to use builtin decoders if you want to scale down less than 50% and a HQ result.

你尝试过这个吗

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

Try this

Bitmap ThumbImage =ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(imagePath),THUMBSIZE, THUMBSIZE);

This Utility is available from API_LEVEl 8. [Source]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM