Search code examples
javaandroidandroid-studiopicasso

How to use Picasso library to crop a picture not from the middle but from the top?


There is a method cropCentre() - it crops in the middle. So is there any similar method, like topCentre() for example?


Solution

  • You can always apply a custom transformation to the fetched Bitmap:

    Picasso.with(context).load(uri).transform(new Transformation() {
            @Override
            public Bitmap transform(Bitmap source) {
                ///Do what you want with bitmap
                return source;
            }
    
            @Override
            public String key() {
                return null;
            }
        }).into(imageView);