facebook / facebook/fresco

Picture just get "blown-up" when I use RoundingParams to get a rounded corner picture

Open
#2,763 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
17.2k
Forks
3.7k
PR merge metrics
No merged PRs in 30d

Description

### Description
I found an issue that seemed to be caused by RoundingParams, but was actually related to the mTargetDensity of the BitmapDrawable which used in RoundedBitmapDrawable

When the density changed by App-Self, the issue maybe appeared.
e.g. [AndroidAutoSize](https://github.com/JessYanCoding/AndroidAutoSize)

I want to getting this:
![image](https://github.com/facebook/fresco/assets/95173094/34868ff8-567d-414d-b776-1344a4861d8f)

But got this:
![image](https://github.com/facebook/fresco/assets/95173094/1544ed6a-bedf-419d-9522-988bf8223dba)

### Reproduction

![image](https://github.com/facebook/fresco/assets/95173094/5dd64ef3-508b-4c16-bed6-fea64dab2449)

### Reason

The "blown-up" effect is the result of the updateTransform function:
https://github.com/facebook/fresco/blob/ba6965409a4d31d86c46771e610771dd37b0d51b/drawee/src/main/java/com/facebook/drawee/drawable/RoundedDrawable.java#L236

Trace the following code:

https://github.com/facebook/fresco/blob/19c695fcc54237497fbc8a4a80c790f63668a0dd/drawee/src/main/java/com/facebook/drawee/drawable/RoundedBitmapDrawable.java#L45

Bitmap which used in RoundedBitmapDrawable was from this code:
https://github.com/facebook/fresco/blob/ba6965409a4d31d86c46771e610771dd37b0d51b/imagepipeline/src/main/java/com/facebook/imagepipeline/platform/DefaultDecoder.java#L276

The density of the bitmap which is created in DefaultDecoder is default, but when update transform in RoundedDrawable will use resource density which is changed by App-Self to measure transform

### Expected

Now, I solved it, by updating density of bitmap in some custom class, such as DrawableFactory or Postprocessor, but it's probably not safe, I hope to get a formal solution

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.