Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setColorFilter not work #10

Open
trongtrong opened this issue May 8, 2020 · 5 comments
Open

setColorFilter not work #10

trongtrong opened this issue May 8, 2020 · 5 comments

Comments

@trongtrong
Copy link

trongtrong commented May 8, 2020

i am load image and set color filter but not work, can you help me ?
GlideToVectorYou
.init()
.with(context)
.withListener(new GlideToVectorYouListener() {
@OverRide
public void onLoadFailed() {
}
@OverRide
public void onResourceReady() {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
holder.imgCategory.setColorFilter(BlendModeColorFilterCompat.createBlendModeColorFilterCompat(ContextCompat.getColor(context, R.color.colorWhite), BlendModeCompat.SRC_ATOP));
} else {
holder.imgCategory.setColorFilter(new
PorterDuffColorFilter(ContextCompat.getColor(context, R.color.colorWhite), PorterDuff.Mode.SRC_IN));
}
}
})
.load(Uri.parse(category.getAvatar()), holder.imgCategory);

@PRobi23
Copy link

PRobi23 commented May 22, 2020

Hello,
I also have this type of error also. I try this in two way:

    GlideToVectorYou
        .init()
        .with(view.context)
        .withListener(object : GlideToVectorYouListener {
            override fun onLoadFailed() {}
            override fun onResourceReady() {
                view.setColorFilter(ContextCompat.getColor(view.context, colorId))
            }
        })
        .load(imageUri, view)

I also tried to set simply the: view.setColorFilter(ContextCompat.getColor(view.context, colorId))

@PRobi23
Copy link

PRobi23 commented May 22, 2020

This worked:

GlideToVectorYou
.init()
.with(view.context)
.withListener(object : GlideToVectorYouListener {
override fun onLoadFailed() {}

            override fun onResourceReady() {
                val paint = Paint()
                paint.colorFilter =
                    PorterDuffColorFilter(ContextCompat.getColor(view.context, colorId), PorterDuff.Mode.SRC_ATOP)
                view.setLayerPaint(paint)
            }
        })
        .load(imageUri, view)

@forfiter91
Copy link

It is possible to add something like tintList to an image with this lib?

@forfiter91
Copy link

For PNG i am doing it as below:
Glide.with(getContext()) .asBitmap() .load(url) .listener(listener) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) { Drawable drawable = new BitmapDrawable(getResources(), resource); Drawable wrappedDrawable = DrawableCompat.wrap(drawable); DrawableCompat.setTintList(wrappedDrawable, mItemColorState); imageButton.setImageDrawable(wrappedDrawable); } }), getContext(), logoUrl);

@YKuvonchbek
Copy link

YKuvonchbek commented Jul 24, 2020

This worked:

GlideToVectorYou
.init()
.with(view.context)
.withListener(object : GlideToVectorYouListener {
override fun onLoadFailed() {}

            override fun onResourceReady() {
                val paint = Paint()
                paint.colorFilter =
                    PorterDuffColorFilter(ContextCompat.getColor(view.context, colorId), PorterDuff.Mode.SRC_ATOP)
                view.setLayerPaint(paint)
            }
        })
        .load(imageUri, view)

It does not work properly. When you set tint color all of the shape colored as solid.
Edit: It works for some type of SVG files, but not all of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants