Faheem Kalsekar
Faheem Kalsekar

Reputation: 1420

Android : Getting Thumbnail Info from an Image

How do i get image thumbnail from the given file path? Here what i am doing

    Intent cameraIntent = new Intent("android.media.action.IMAGE_CAPTURE");
    startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);

On "onActivityResult", i get the image in Intent data.

I want to extract thumbnail info from this image. How do i extract it, so that i can show that thumbnail as preview

Upvotes: 2

Views: 5046

Answers (4)

R3V0LUT10N 909
R3V0LUT10N 909

Reputation: 1560

Check out the thumbnail generation routines for media provider: http://developer.android.com/reference/android/media/ThumbnailUtils.html

Bitmap thumbBitmap = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(filePath), thumbWidth, thumbHeight);

Upvotes: 1

Abhinav
Abhinav

Reputation: 39942

Check out the thumbnail generation class inside Android itself - http://developer.android.com/reference/android/media/ThumbnailUtils.html

It's available since API level 8.

Upvotes: 0

Asaf Pinhassi
Asaf Pinhassi

Reputation: 15573

Once you have the bitmap, you can convert it to a thumbnail using createScaledBitmap (Bitmap src, int dstWidth, int dstHeight, boolean filter) or, for Android2.2 and up, using Bitmap extractThumbnail (Bitmap source, int width, int height).

Upvotes: 2

Matt
Matt

Reputation: 3847

I think you'll have to get the full image and either scale it, or decode it specifying inSampleSize>1 in BitmapFactory.Options.

Upvotes: 0

Related Questions