Scaling up image with RoundingParams works wrong (Android 9.0)
See original GitHub issueDescription
Hello, I’ve found a problem with scaling up images with Fresco with rounding params in Android 9.0.
When image is small and it need to be scaled up to fill View (with CENTER_CROP ScaleType for example) it displays with artifacts. Looks like pixels are not interpolated to fill the view, but scaled separately and image looks pixelated
At the screenshot: top picture looks as expected, and the bottom one (with rounding) pixelated
Reproduction
run code on Android 9 device (reprodused on Samsung Galaxy S 9 and Pixel 2)
public class MainActivity extends AppCompatActivity {
private static final String SMALL_IMAGE_URL = "https://www.dropbox.com/s/5mxb5a2mae773c9/small.jpg?dl=1";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fresco.initialize(this);
LinearLayout root = new LinearLayout(this);
root.setOrientation(LinearLayout.VERTICAL);
root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
//first view without rounding
SimpleDraweeView firstImage = new SimpleDraweeView(this);
firstImage.setImageURI(SMALL_IMAGE_URL);
firstImage.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);
root.addView(firstImage, paramsForImage());
//same view, but with rounding
SimpleDraweeView secondImage = new SimpleDraweeView(this);
secondImage.setImageURI(SMALL_IMAGE_URL);
secondImage.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);
secondImage.getHierarchy().setRoundingParams(RoundingParams.fromCornersRadius(24));
root.addView(secondImage, paramsForImage());
setContentView(root);
}
private LinearLayout.LayoutParams paramsForImage() {
LinearLayout.LayoutParams result = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
result.weight = 1;
return result;
}
}
Additional Information
May be BitmapShader, which is used for rounding, works unexpected at Android 9.0 Rounding with overlay color works fine
- Fresco version: 1.12.1
- Platform version: Android 9.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Bad image quality after resizing/scaling bitmap - Stack Overflow
Use createScaledBitmap will make your image looks very bad. I've met this problem and I've resolved it. Below code will fix the problem:...
Read more >Rounded Corners and Circles - Fresco
One workaround is to use a different scale type (e.g. centerCrop) that ensures that the whole view is covered. Another workaround is to...
Read more >Scaling Images In Android Not Working Like Supposed To ...
Scaling Images In Android Not Working Like Supposed To With Code Solution Hello everyone, in this post we will look at how to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should be fixed with 6d3a538525d2eab10bd59400ee1fcaf9569bdf79. Thanks @otopba!
@oprisnik I use both rounding corners and circle rounding. Thank you for BitmapTransformation hint, I’ll try it