Android: Question about Bitmaps, memory usage, and scaling

前端 未结 3 1820
野性不改
野性不改 2021-02-02 17:01

For readibility, I posted the code examples that my solutions refer to first, and thenI listed the explanations of my solutions in a numerical list.

I have been

3条回答
  •  醉话见心
    2021-02-02 17:15

    The problem of the android heap is, that you actually don't know how much of the heap you may use, because any background service could at any time ruin everything for you, if you overstep the memory constraints.

    Why don't you just keep one Bitmap the size of the canvas you are always drawing on, and a stack of downsampled bitmaps? You could then render all image in native solution to your canvas, and always draw your downsampled bitmaps for any change that occurs. Once the change is over, or it is clear which image is most important, redraw that one in native resolution to the canvas (by accessing the disk again).

提交回复
热议问题