// 第一种:直接载入图片
public static Bitmap getBitmap(String path) {
Bitmap bt = BitmapFactory.decodeFile(path);
return bt;
}
//第二种: 按指定大小载入
public static Bitmap getBitmap(String path, int size) {
Options op = new Options();
op.inSampleSize = size;
Bitmap bt = BitmapFactory.decodeFile(path, op);
return bt;
}
//第三种: 按照宽高压缩载入
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;
}
public static Bitmap getBitmap(String path) {
Bitmap bt = BitmapFactory.decodeFile(path);
return bt;
}
//第二种: 按指定大小载入
public static Bitmap getBitmap(String path, int size) {
Options op = new Options();
op.inSampleSize = size;
Bitmap bt = BitmapFactory.decodeFile(path, op);
return bt;
}
//第三种: 按照宽高压缩载入
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;
}