get Thumbnail Image From Path - Android Graphics

Android examples for Graphics:Bitmap Thumbnail

Description

get Thumbnail Image From Path

Demo Code


//package com.java2s;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import android.media.ThumbnailUtils;

public class Main {
    private static final int MOSAIC_IMAGE_SIDE = 400;

    private static Bitmap getThumbnailFromPath(String imagePath) {
        Bitmap bitmap = null;//from  ww  w .  j av a2s  . c  o m

        bitmap = BitmapFactory.decodeFile(imagePath);
        if (bitmap == null) {
            bitmap = Bitmap.createBitmap(MOSAIC_IMAGE_SIDE,
                    MOSAIC_IMAGE_SIDE, Bitmap.Config.ARGB_8888);
        }
        bitmap = ThumbnailUtils.extractThumbnail(bitmap, MOSAIC_IMAGE_SIDE,
                MOSAIC_IMAGE_SIDE);

        return bitmap;
    }
}

Related Tutorials