I don't believe this is a question limited to live wallpapers, but it is the use case I am trying to work with.
I have a 256 x 256 bitmap created as a "tile" for my live wallpaper. I am looking for a memory efficient way to scale this to fit an entire device screen. I continue to run into "exceeding VM memory" issues whenever the device rotates back and forth, which suggests I am not handling the problem correctly.
The image is being drawn using Canvas' drawBitmap()
method. I have tried the following options:
- Create the bitmap, then call
createScaledBitmap()
- Create the bitmap, then call
scale()
on my canvas - Create the bitmap, then create a matrix to "stretch" the width and height, and apply it with a
preScale()
If I call recycle()
the live wallpaper runs for one frame, then crashes. If I don't rotate the device at all, I get no out of memory crashes.
Thanks for any suggestions!