How to get the received raster image of the image after it has been changed into the image from Picasso

I am trying to resize an image from my gallery to fit the image and save its bitmap after fitting so that I can upload it to my Parse database when I click the add button. Currently, when the "Add" button is clicked, I check if the bitmap is zero, and if not, convert it to Parsefile, which will be saved in my analysis database. Adding to the database works (I tested this without using Picasso), but I'm not sure how to get the bitmap if I use Picasso to resize and load. I tried to create a Target and use its callbacks, but I cannot use .fit () for the purpose. I resorted to using a callback, but I was hoping for a better way to achieve preservation of the bitmap.

Here's what I'm doing right now, trying to get a bitmap from an image after downloading it:

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 } }); } 
+5
source share
1 answer

You can use callback

  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() { } }); 
0
source

Source: https://habr.com/ru/post/1200390/


All Articles