使用滑行库的图像灰度 [英] Image grayscale using glide library

查看:55
本文介绍了使用滑行库的图像灰度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用glide库在图像视图中加载图像url.

I am using glide library to load image url in image view.

Glide.with(context)
                .load(imageurl)
                .apply(RequestOptions.circleCropTransform())
                .into(holder.thumbnail);

实际上,该图像很好地加载了带有四舍五入的图像.

Actually, the image is loaded fine with rounded image.

我需要在图片上添加四舍五入的+ 灰度图片

I need the image to be loaded with rounded + grayscale image

这可以通过使用glide lib来完成吗?

Can this be done by using glide lib?

推荐答案

您可以使用Android的 android.graphics.ColorMatrix 类将饱和度设置为0,以使ImageView灰度.

You can use Android's android.graphics.ColorMatrix class to set the saturation to 0 for making an ImageView grayscale.

您可以分两步实现您想要的. 1.使用Glide使ImageView变圆. 2.之后,使用ColorMatrix类使ImageView灰度.

You can achieve what you want in two steps. 1. Use Glide to make the ImageView rounded. 2. After that use ColorMatrix class to make the ImageView grayscale.

Glide.with(context)
.load(imageurl)
.apply(RequestOptions.circleCropTransform())
.into(holder.thumbnail);

ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(colorMatrix);
holder.thumbnail.setColorFilter(filter);

这篇关于使用滑行库的图像灰度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆