feat Bitmap - Android Graphics

Android examples for Graphics:Bitmap Effect

Description

feat Bitmap

Demo Code


//package com.book2s;

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

public class Main {
    public static Bitmap featBitmap(String path, int width) {
        Bitmap bitmap = null;/*from   w  w  w.  ja v a2 s .c  om*/
        try {
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeFile(path, options);
            options.inJustDecodeBounds = false;
            options.inSampleSize = 1;
            options.inPreferredConfig = Bitmap.Config.RGB_565;
            options.inPurgeable = true;
            options.inInputShareable = true;
            int bitmap_w = options.outWidth;
            while (bitmap_w / (float) width > 2) {
                options.inSampleSize <<= 1;
                bitmap_w >>= 1;
            }
            return BitmapFactory.decodeFile(path, options);
        } catch (Exception e) {
        }
        return bitmap;
    }
}

Related Tutorials