第一种用BitmapFactory.Options
private Bitmap scaleCreateBitmap(String path, int targetWidth, int targetHeight) {
path = "/storage/emulated/0/arhomework/test_get_answer/key_store_bitmap_file.jpg";
targetWidth = 100;
targetHeight = 100;
int sampleSize = 0;
int sampleSizeIndex = 0;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmap bitmap = null;
do {
sampleSize = (int) Math.pow(2, sampleSizeIndex++);
options.inSampleSize = sampleSize;
BitmapFactory.decodeFile(path, options);
} while (options.outWidth > targetWidth || options.outHeight > targetHeight);
options.inJustDecodeBounds = false;
bitmap = BitmapFactory.decodeFile(path, options);
Log.e("testCreateBitmap", &#