我想调整图像大小,并使用滑行。我从文件中加载图片,我想调整图片的大小,然后将调整后的图片保存到同一文件中
public static void minimizeImageWithPicasso(Context context, final File file, int targetSize, Handler handler) {
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file.getPath(), options);
float ratio = Math.max(options.outWidth, options.outHeight) / (float) targetSize;
//don't scale image that is smaller than targetSize
if (ratio < 1) return;
int dstWidth = (int) (options.outWidth / ratio);
int dstHeight = (int) (options.outHeight / ratio);
Glide
.with(context)
.load(file)
.asBitmap()
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(new FileTarget(file.getAbsolutePath(), dstWidth, dstHeight));
}
我这样做了,但是它不能将照片转换为文件