Created
August 15, 2021 10:17
-
-
Save frel/ca85e79cacd11b8a5a6ae6ec194c18c4 to your computer and use it in GitHub Desktop.
AirBrush Medium article example
This file contains hidden or 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
@GlideModule | |
class GlideModule : AppGlideModule() { | |
override fun registerComponents(context: Context, glide: Glide, registry: Registry) { | |
// Register a ModelLoaderFactory for TinyThumb allowing the type to be loaded using Glide | |
registry.append(TinyThumb::class.java, TinyThumb::class.java, TinyThumbLoader.Factory()) | |
// Register a ResourceDecoder for TinyThumb. Specifying the input and output type. | |
// Note that the tailing lambda is the blur provider. If we wanted to use another blur | |
// implementation we could replace it here. | |
registry.append( | |
TinyThumb::class.java, | |
BitmapDrawable::class.java, | |
TinyThumbDecoder(context, glide.bitmapPool) { bitmap, options -> | |
// The options parameter is an optional override, allowing per request blur values | |
// such as radius and sample size. The default radius depends on your use case(s). | |
val radius = options?.radius ?: 15f | |
AirBrush.blur(context, bitmap, scale = 1f, radius = radius) | |
} | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment