Created
October 20, 2017 10:15
-
-
Save vashisthg/3760502fc911db876546b894c265eac0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment