Optimal use of BitmapFactory.Options.inSampleSize for speed

前端 未结 4 1534
野的像风
野的像风 2021-02-05 05:15

Thanks to Schermvlieger for asking this question on anddev.org,

I\'m just copying his question to SO as nobody replied on th

4条回答
  •  醉梦人生
    2021-02-05 05:47

    You should always try to load and pre-scale images so that they are as close as possible to their final displayed size. Scaling images at drawing time is extremely expensive and should be avoided at all cost.

    Considering the memory cost of an image, yes, the color-deptch plays a very important role. Images in ALPHA_8 format use 1 byte per pixel, images in RGB_565 or ARGB_4444 use 2 bytes per pixel and images in ARGB_8888 use 4 bytes per pixel. The depth of the display does not matter at all. You should always try to use ARGB_8888 to get the best possible quality, but 565 can be good enough if your image is opaque.

提交回复
热议问题