偷懒代码块之图片按比例缩放

public static Bitmap getThumbnailBitmap(Context context, int resId, int scale) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = scale;//缩放倍数
        options.inJustDecodeBounds = false;
        Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resId, options);
        //可以通过其他解码方式解码获得压缩图片
        return bitmap;
    }

你可能感兴趣的:(偷懒代码块之图片按比例缩放)