is there a way to pass either a bitmap-config or force this BitmapConfig? I would like to not do it via Transformation() as this would consume more CPU than needed and I am not sure if this is done before the cache ( my main reason to do this is that the images in the cache should not consume that much memory )
I found the solution - picasso 2.2.0 has now an API for this - was using 2.1.1 before and there was no API for this. Looks like this then:
picasso.load(url).config(Bitmap.Config.RGB_565).into(target);
I have found a nice solution, that works very fine and 100%
(Sorry but answer of @ligi not works for me])
Use this util class for any picasso bitmap changes (here is RGB565)
Note also that Picasso build singleton class
So this only changes will cover all others (also if you don't plan to use RGB565 everywhere)
import com.squareup.picasso.Transformation;
public class Config565Transformation implements Transformation {
@Override
public Bitmap transform(Bitmap source) {
Bitmap resultBitmap = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(resultBitmap);
Paint paint = new Paint();
paint.setFilterBitmap(true);
canvas.drawBitmap(source, 0, 0, paint);
source.recycle();
return resultBitmap;
}
@Override
public String key() {
return Config565Transformation.class.getSimpleName();
}
}
and simply use it
Picasso.with(getContext())
.load(url)
.transform(new Config565Transformation())
.into(imageView);
Reference: https://habrahabr.ru/post/218453/
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