Open zengjingfang opened 3 years ago
centerCrop means you want the image to fill the view. You can override that with one of the other transformations as you've noted.
By default we upscale images so that we can maximize bitmap pool hit rates (we hope). That's kind of legacy behavior at this point, but it's hard to change the default without breaking a bunch of apps.
@sjudd the "bitmap pool hit rates" you say is "LruBitmapPool" ? If it is, i don't think so . On our application business , if the picture is small than view ,it is aways full screen background or very big view. On this case, We should focus on memory allocated more。
If we decode by picture size, it does not influence the bitmap pool "hit rates",because next picture will be same size also.
And on the other hand, for my test ,cpu will be lower when decodeBitmap for smaller size.
As your say, there is kind of legacy behavior ,and you can not change it just consider the impact on other apps?
I changed it on my app(exactScaleFactor <=1 ), and it better or worse for my business on your opinion?
according to the annotation of BitmapFactory.inScaled, "the bitmap will be scaled to match inTargetDensity when loaded, rather than relying on the graphics system scaling it each time it is drawn to a Canvas." , maybe this is also a reason. But i also don't think it is worse to waste memory.
ForMy Test: exactScaleFactor will >1 when original picture < view ,then the bitmap size will be larger than original picture, there is waste too mush native memory. why ?
For example: My picture is 750x1733,but bitmap decode is 1176x2091,transform centerCrop will be 1080x2091。 At last: there is create two bitmap, and all larger than picture。 My device screen: 1080 x 2091
Glide.with(MainActivity.this).load("xxx").into(imageView);