use*_*182 5 android bitmap imageview picasso
我正在尝试重新调整图库中的图片以适应图像视图并在合身后保存其位图,这样我就可以通过按下"添加"按钮将其上传到我的Parse数据库.目前,当按下"add"时,我检查位图是否为空,如果不是,则将其转换为Parsefile以保存在我的Parse数据库中.添加到数据库工作(我测试了这个没有使用Picasso),但我不知道如果我使用Picasso调整大小和加载如何获取位图.我尝试创建一个目标并使用它的回调,但我不能在目标上使用.fit().我已经使用回调,但我希望有更好的方法来实现位图的保存.
这就是我现在正在做的事情,尝试在加载后从imageview获取位图:
if(uri != null) {
Picasso.with(mContext).load(uri).skipMemoryCache().fit().centerCrop().into(imgPreview, new Callback() {
@Override
public void onSuccess() {
mBitmap = ((BitmapDrawable)imgPreview.getDrawable()).getBitmap();
}
@Override
public void onError() {
// TODO Auto-generated method stub
}
});
}
Run Code Online (Sandbox Code Playgroud)
您可以使用回调
Picasso.with(context)
.load(absolutePath)
.fit()
.noFade()
.centerInside()
.placeholder(R.drawable.image_holder)
.memoryPolicy(MemoryPolicy.NO_CACHE)
.into(imageView, new Callback() {
@Override
public void onSuccess() {
// You can do anything here because your imageView now has the bitmap set
}
@Override
public void onError() {
}
});
Run Code Online (Sandbox Code Playgroud)