Guest User

Untitled

a guest
Oct 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import android.graphics.Bitmap
  2. import timber.log.Timber
  3.  
  4. /**
  5. * Picasso transformation to Crop an image from top.
  6. * Created by Gaurav Vashisth on 20/10/17.
  7. */
  8.  
  9. class CropFromTopTransformation constructor(private val cropDistance: Int): com.squareup.picasso.Transformation {
  10.  
  11. override fun transform(source: Bitmap): Bitmap {
  12. val width = source.width
  13. val height = source.height
  14.  
  15. val clipImage = Bitmap.createBitmap(source, 0, cropDistance, width, height - cropDistance);
  16.  
  17. if (source != clipImage) {
  18. source.recycle()
  19. }
  20. return clipImage
  21. }
  22.  
  23. override fun key(): String {
  24. return "CropFromTopTransformation" + cropDistance
  25. }
  26. }
Add Comment
Please, Sign In to add comment