Github最火开源项目-三分钟学会使用Glide-Transformation

本文介绍了一个基于Glide的开源项目Glide-transformations,通过简单的配置即可为图片加载添加多种视觉效果,包括但不限于圆形裁剪、模糊、圆角、遮盖、灰度等。

结合Glide实现很炫的图片效果框架

开源项目地址:https://github.com/open-android/Glide-transformations

PS:如果觉得文章太长,你也可观看该课程的视频,亲,里面还有高清,无码的福利喔

运行效果

  • 欢迎关注微信公众号

微信公众号名称:Android干货程序员

使用步骤

1. 在project的build.gradle添加如下代码(如下图)

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

2. 在Module的build.gradle添加依赖

compile 'com.github.open-android:Glide-transformations:0.1.0'

3. 使用Picasso加载图片时添加显示效果

   Glide.with(context) 
    .load(url) 
 .transform(new CropCircleTransformation())//图片最终会展示出圆形区域
    .into(view);
Glide-transformations 是通过Glide加载图片中通过上面的transform可以设置图片展示的效果  CropCircleTransformation是圆形效果,还有很多其他的效果

模糊效果
Glide.with(this)
.load(R.mipmap.ic_image_sample)
    .bitmapTransform(new BlurTransformation(this))
    .into(mResultIv);

圆角效果
Glide.with(this).load(R.mipmap.ic_image_sample)
    .bitmapTransform(new RoundedCornersTransformation(this, 24, 0, 
        RoundedCornersTransformation.CornerType.ALL))
    .into(mResultIv);

遮盖效果
Glide.with(this).load(R.mipmap.ic_image_sample)
    .bitmapTransform(new MaskTransformation(this, R.mipmap.ic_launcher))
    .into(mResultIv);

灰度效果
Glide.with(this).load(R.mipmap.ic_image_sample)
    .bitmapTransform(new GrayscaleTransformation(this))
    .into(mResultIv);

其他效果
ToonFilterTransformation
SepiaFilterTransformation
ContrastFilterTransformation
InvertFilterTransformation
PixelationFilterTransformation
SketchFilterTransformation
SwirlFilterTransformation
BrightnessFilterTransformation
KuwaharaFilterTransformation
VignetteFilterTransformation
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值