【发布时间】:2018-09-26 12:34:44
【问题描述】:
我想调整 glide 使用的图像大小。现在我用毕加索,但我想用滑翔机
private void resizeImg(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);
PicassoTargetFactory.getInstance().putTarget(file, handler);
Picasso.with(context)
.load(file)
.error(R.drawable.ic_delete)
.resize(dstWidth, dstHeight)
.into(PicassoTargetFactory.getInstance().getTarget(file));
ArrayList<String> paths = new ArrayList<>();
files = new ArrayList<>();
files.add(mCurrentPhotoPath);
for (File f : files) {
paths.add(f.getAbsolutePath());
}
mdb.insertPhotos(paths);
}
我该怎么做?在 piccaso 上有时我有一个剪切图像
【问题讨论】:
-
@NileshRathod 好的,但我想调整图像大小并将其保存到文件中