Package smalt.music.utils;
import Android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
//Loading pictures in 3 ways:
Public class Bitmapuntil {
// loading pictures directly
Public static Bitmap Getbitmap (String path) {
Bitmap bt = bitmapfactory.decodefile (path);
return BT;
}
//Specify size load picture
Public static Bitmap Getbitmap (String path, int size) {
Options op = new options ();
op.insamplesize = size;
Bitmap bt = bitmapfactory.decodefile (path, op);
return BT; Www.2cto.com
}
// load pictures by wide-height compression
Public static Bitmap Getbitmap (String path, int width, int heigh) {
Options op = new options ();
op.injustdecodebounds = true;
Bitmap bt = bitmapfactory.decodefile (path, op);
int xscale = op.outwidth/width;
int yscale = Op.outheight/heigh;
Op.insamplesize = XScale > Yscale?
Xscale:yscale;
op.injustdecodebounds = false;
BT = bitmapfactory.decodefile (path, op);
return BT;
}
}
Android three ways to load pictures