0

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;
    }
Erick
  • 715
  • 1
  • 8
  • 15
  • Which language version and which platform are you developing on? Are you developing web application that serves content to an android browser? – Benedikt Dec 10 '13 at 08:05
  • Im using java in android. I have this native android application with a custom camera and I want to create a thumbnail of my captured image. – Erick Dec 10 '13 at 08:11
  • Show us some code of what you tried. I could define nice thumbnails using only android apis. – Snicolas Dec 10 '13 at 08:19
  • @Snicolas , I post some codes. kindly check. :) – Erick Dec 10 '13 at 08:27
  • 1
    You should have a look at this : http://developer.android.com/training/displaying-bitmaps/load-bitmap.html. And this http://stackoverflow.com/a/19486896/693752 – Snicolas Dec 10 '13 at 12:18

3 Answers3

0

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.

S.M.Mousavi
  • 5,013
  • 7
  • 44
  • 59
-1

Did you try this,

Bitmap src = Thumbnails.getThumbnail(getContentResolver(), ContentUris.parseId(sourceUri), Thumbnails.MINI_KIND, options);
Shashika
  • 1,151
  • 1
  • 9
  • 21
-2

Try this

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

This Utility is available from API_LEVEl 8. [Source]

Vipul Divyanshu
  • 196
  • 2
  • 6