Open mezentsev opened 2 years ago
Hi,
Thanks for the detailed bug report. The AVIF integration supports images with alpha channel.
Do you have an AppGlideModule to activate the AVIF integration? Without the AppGlideModule, Glide will try to decode the AVIF images using the platform's AVIF decoder (it will be available on android versions >= 12). The platform decoder does NOT support alpha channel and would result in images being rendered as you have shared.
A sample empty app glide module:
@GlideModule
public final class YourAppGlideModule extends AppGlideModule {}
I am able to reproduce this on my pixel 3. Without the app glide module, i see images rendered similar to yours. With the app glide module, i see the images rendered correctly with transparency based on whether or not dark mode is enabled in the system settings.
Here is how it renders on my Pixel 3 with the correct app glide module.
Light Mode:
Dark Mode:
Hope that helps. Please let me know if you have any further questions.
same problem with this file,on system version below android 12 051b5f213ab01a4c.png.avif.zip
@vigneshvg Thanks for answer. It helps for main purposes but not for Targets. I found a problem with loading via CustomViewTarget. I'd share an example:
// ...
val target = glideTarget(tariffImage) ?: object : CustomViewTarget<ImageView, Drawable>(myImageView) {
override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
getView().setImageDrawable(resource)
}
override fun onLoadFailed(errorDrawable: Drawable?) {
// no-op
}
override fun onResourceCleared(placeholder: Drawable?) {
// no-op
}
}
saveTarget(tariffImage, target)
Glide.with(myImageView)
.load(iconUrl)
.into(target)
}
// ...
private fun saveTarget(view: View, glideTarget: Target<Drawable>) {
view.setTag(R.id.image_view_tag_glide_target, glideTarget)
}
private fun glideTarget(view: View): Target<Drawable>? {
return view.getTag(R.id.image_view_tag_glide_target) as? Target<Drawable>
}
That example shows white background for AVIF.
But I watched througth the source code and found interesting moment with ImageView:
glideContext.buildImageViewTarget(view, transcodeClass)
that helps
I use glide
4.13.2
with avif supportbut I am stuck with transparent layer. All images got problems with background: green, black or problems with displaying.
Example avifs with device output All avifs and device output screens
How Glide renders it on my Pixel 5
Black background instead of transparancy
Black background instead of transparancy
No image, bu transparancy :)
Green background instead of transparancy
Black background instead of transparancy
You can find all avifs by link above.
Device: Pixel 5 Android 12
Is it a known problem? I saw the similar problem in #4751