I'm using Picasso library for load images in a viewpager, but I need to load a bitmap and Picasso accept only File variable. How can I load bitmap file using Picasso?
Bitmap imagescompress = decodeSampledBitmapFromResource(getResources(), AnohanaAdapter.imagep[position], 100, 100);
If I put imagecompress in the load function of Picasso, I've this error: Cannot resolve method 'load(android.graphics.Bitmap)'.
Actually for load images I use below code:
Picasso.with(VistaSingola.this).load(AnohanaAdapter.imagep[i]).placeholder(R.drawable.ic_launcher).error(R.drawable.error).fit().into(imageViewTouch);
But images are big and I don't want to go in OutOfMemory. Someone can help me? Please.
Thank you all help me
You can use bellow code to do this
private Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
//TODO: Store bitmap in global vaiable
}
@Override
public void onBitmapFailed() {
}
}
private void loadBitmap(String url) {
Picasso.with(this).load(url).into(target);
}
@Override
public void onDestroy() { // could be in onPause or onStop
Picasso.with(this).cancelRequest(target);
super.onDestroy();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With