Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.graphics.Bitmap
- import timber.log.Timber
- /**
- * Picasso transformation to Crop an image from top.
- * Created by Gaurav Vashisth on 20/10/17.
- */
- class CropFromTopTransformation constructor(private val cropDistance: Int): com.squareup.picasso.Transformation {
- override fun transform(source: Bitmap): Bitmap {
- val width = source.width
- val height = source.height
- val clipImage = Bitmap.createBitmap(source, 0, cropDistance, width, height - cropDistance);
- if (source != clipImage) {
- source.recycle()
- }
- return clipImage
- }
- override fun key(): String {
- return "CropFromTopTransformation" + cropDistance
- }
- }
Add Comment
Please, Sign In to add comment