Wednesday, March 23, 2011

[android-developers] Re: bitmap size exceeds VM budget on BitmapFactory.decodeResource

I have to stop answering queries, someone else always comes along with
a much better answer :-)

Pent

On Mar 22, 10:03 am, String <sterling.ud...@googlemail.com> wrote:
> As someone who's done a bunch of similar work, I'm afraid the short answer
> is: you can't do that.
>
> The slightly longer answer: As your math shows, simply loading the
> WVGA-scale bitmaps blows out the 16MB limit. Now, my understanding is that a
> Galaxy S should have 24MB of heap, but still - you're pushing it. Between
> the unavoidable couple of MB that all Android apps use, whatever else your
> code needs, and (most crucially for you) a bit of room to assemble the final
> wallpaper image, you're still going well over the limit.
>
> A few things you might try to mitigate the situation:
> - Rearrange your code so that you only load one source image at a time, do
> what you need to with it, then clear it from RAM with a recycle() call.
> - Avoid the ARGB_8888 config. If you need transparency, use ARGB_4444,
> otherwise go with RGB_565.
> - As Pent suggested, downsample your images. But that essentially just
> decreases the resolution, with a corresponding increase in pixellation.
>
> String

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment