Mutating a drawable does not making the Bitmap it may contain mutable. You have to check whether the Bitmap you get is mutable. Bitmaps loaded from resources are never mutable, you must create a mutable copy first (see the Bitmap.create/copy documentation.)
On Mon, Aug 30, 2010 at 12:53 AM, Ed <edscha...@gmail.com> wrote: > Hi all, > > Found a bit of a weird one which might be related to this post - > http://groups.google.com/group/android-developers/browse_thread/thread/b0e2048495d61e0c > > I've check the public issue tracker for android and can't see anything > related to this. > > Basically I'm setting an icon in a menu, getting a mutable copy of the > icon, drawing some text on it to create a menu item that reflects the > current state of the thing the menu item links to. > > This works all well and good when I use a resource that is in / > drawble/ but if I put the same resource into /drawable/hdpi/ (with > relevant resizes in ldpi and mdpi) it blows up saying that it is not > mutable... even though it's using the same code and the same image > format (exactly the same file): > > Drawable d = mi.getIcon().mutate(); > Canvas c = new Canvas(((BitmapDrawable) d).getBitmap()); > //draw on canvas > d.draw(c); > > I wish to use the different dpi graphics as appropriate rather than > scaling at runtime or implementing my own dpi image selector. Is this > a known limitation? If so is there documentation about it? > > Cheers, > > Ed > > -- > 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+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en