Example usage for android.media ThumbnailUtils extractThumbnail

List of usage examples for android.media ThumbnailUtils extractThumbnail

Introduction

In this page you can find the example usage for android.media ThumbnailUtils extractThumbnail.

Prototype

public static Bitmap extractThumbnail(Bitmap source, int width, int height, int options) 

Source Link

Document

Creates a centered bitmap of the desired size.

Usage

From source file:Main.java

public static Bitmap getBitmapThumbnail(Bitmap bmp, int width, int height) {
    Bitmap bitmap = null;// w w  w . j  a v a  2s. c  o m
    if (bmp != null) {
        bitmap = ThumbnailUtils.extractThumbnail(bmp, width, height, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
    }
    return bitmap;
}

From source file:Main.java

public static Bitmap createVideoThumbnail(String vidioPath, int width, int height, int kind) {
    Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(vidioPath, kind);
    bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
    return bitmap;
}

From source file:Main.java

public static Bitmap getVideoThumbnail(String videoPath, int width, int height, int kind) {
    Bitmap bitmap;/*from  w  w w . j  a  va 2s  . c  om*/
    bitmap = ThumbnailUtils.createVideoThumbnail(videoPath, kind);
    bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
    return bitmap;
}

From source file:Main.java

public static Bitmap getVideoThumbnail(String videoPath, int width, int height, int kind) {
    Bitmap bitmap = null;/*from w w  w .  j a va 2s .c o m*/
    bitmap = ThumbnailUtils.createVideoThumbnail(videoPath, kind);
    bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
    return bitmap;
}

From source file:Main.java

public static Bitmap getVideoThumbnail(String filePath, int width, int height, int kind) {
    Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(filePath, kind);
    bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
    return bitmap;
}

From source file:Main.java

public static Bitmap compressAccordingToWidth(Bitmap bitmap, int width) {

    if (width == bitmap.getWidth()) {
        return bitmap;
    }/*from  w  w  w.  j av a 2  s. c o  m*/

    float scale = (float) width / (float) bitmap.getWidth();
    int height = (int) (bitmap.getHeight() * scale);

    return ThumbnailUtils.extractThumbnail(bitmap, width, height, 0);
}

From source file:Main.java

public static Bitmap getApkResizedIcon(Context context, String apkPath, int width, int height) {
    Bitmap thumb = getApkIcon(context, apkPath);
    if (thumb != null) {
        return ThumbnailUtils.extractThumbnail(thumb, width, height, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
    }// w  w w . j  a v a 2  s  . c  om
    return thumb;
}

From source file:Main.java

public static Bitmap getVideoImage(String urlPath) {
    Bitmap bitmap = null;//w w w.j  a  v  a 2  s.  c o m
    bitmap = ThumbnailUtils.createVideoThumbnail(urlPath, MediaStore.Images.Thumbnails.MICRO_KIND);
    bitmap = ThumbnailUtils.extractThumbnail(bitmap, 100, 80, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
    return bitmap;
}

From source file:Main.java

@Deprecated
public static Bitmap getBitmapThumbnail(Bitmap source, int width, int height) {
    return ThumbnailUtils.extractThumbnail(source, width, height, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
}

From source file:Main.java

private static Bitmap adjustDisplayImage(String path, int width, int hight) {
    BitmapFactory.Options opts = getBitmapOptions(path);
    int srcWidth = opts.outWidth;
    int srcHeight = opts.outHeight;

    Bitmap compressedBitmap = null;//from   w  ww  .  ja v  a 2  s  . c o  m
    Bitmap thumbnailBitmap = null;
    try {
        thumbnailBitmap = getThumbnail(path, width, hight);
        if (null == thumbnailBitmap) {
            return null;
        }
        compressedBitmap = ThumbnailUtils.extractThumbnail(thumbnailBitmap, width, hight, 1);
    } catch (Error e) {

        return null;
    } finally {
        if (thumbnailBitmap != null) {
            thumbnailBitmap.recycle();
            thumbnailBitmap = null;
        }
    }

    return compressedBitmap;
}