Quick update:

Android 3.0 will give you the ability to load mutable bitmaps from
BitmapFactory. The API relies on BitmapFactory.Options, and a new field call
"inMutable." While I'm at it, know that we've added another API to
BitmapFactory.Options that lets you decode a Bitmap into an existing bitmap
(provided their size and configuration match.) By using
BitmapFactory.Options.inBitmap you can reuse the same bitmap over and over
again and save memory.

On Mon, Jan 17, 2011 at 12:05 PM, Streets Of Boston <flyingdutc...@gmail.com
> wrote:

> I would vote with all my 4 thumbs up for the *option* of creating a
> mutable bitmap from a file/input-stream/etc. For optimizations, the
> default should still be immutable bitmaps (as you described), but an
> option for loading it into a mutable bitmap would be great!.
>
> Question:
> Is there a way around this in Android2.2, by using the Bitmap's *NDK*
> api?
>
>
>
> On Jan 17, 2:55 pm, Romain Guy <romain...@android.com> wrote:
> > I'll try to add a new API to load mutable bitmaps from BitmapFactory but
> I
> > can't make any guarantee as to when it will be added to the platform
> (it's
> > doubtful it will be in the first release of Android 3.0.) The main reason
> > why bitmaps are mutable when loaded from a BitmapFactory is optimization.
> > When a Bitmap is immutable the rendering layer might be able to draw it
> more
> > efficiently. Also, when a Bitmap is loaded from resources and used in
> > drawables, it is shared by all the drawables. It's also better to have
> > immutable bitmaps when recording pictures (which is what WebView does for
> > faster rendering.)
> >
> > As for your Log.d issue, I have never used a Galay Tab, so I have no
> idea.
> > I've used Log.d successfully on numerous other devices though.
> >
> >
> >
> >
> >
> > On Mon, Jan 17, 2011 at 11:46 AM, Matthew Fleming <mgf...@gmail.com>
> wrote:
> > > Thanks very much for the explanation regarding the 3 memory functions.
> > > I should have known this; my mistake.
> >
> > > I really wish Google would consider modifying the BitmapFactory
> > > methods to allow for loading a mutable bitmap from a file/stream/
> > > resource. The current arrangement has no obvious justification, and,
> > > judging from a few postings here and there, has caused problems for
> > > other developers as well.
> >
> > > Any thoughts on why I can't use Log.d with actual hardware?
> >
> > > Matthew Fleming
> >
> > > On Jan 17, 12:44 pm, Romain Guy <romain...@android.com> wrote:
> > > > Hi Matthew,
> >
> > > > I am sorry that you didn't get a better answer before, but this is,
> > > > unfortunately, the only way of doing it with the existing APIs. This
> kind
> > > of
> > > > feedback is important to us because it tells us what APIs application
> > > > developers need.
> >
> > > > As for your second question, the values returned are expected.
> > > > Runtime.freeMemory() tells you how much you can still allocate on the
> > > heap
> > > > before it needs to expand. Runtime.totalMemory() indicates the
> current
> > > size
> > > > of the heap, and Runtime.maxMemory() tells you how big the heap can
> be
> > > > before your run out of memory.
> >
> > > > On Mon, Jan 17, 2011 at 4:18 AM, Matthew Fleming <mgf...@gmail.com>
> > > wrote:
> > > > > Hi,
> >
> > > > > I posted earlier about my need to find a way to load a mutable
> bitmap.
> > > > > I need to be able to load a bitmap from an input stream, annotate
> it,
> > > > > and save it. At present, the only thing I seem to be able to do is
> > > > > load an immutable bitmap, copy it, annotate the copy, and then save
> > > > > that. THIS IS NOT A SOLUTION, because then I need memory for two
> > > > > copies of the bitmap, and I am working with large images.
> >
> > > > > COULD SOMEONE FROM GOOGLE PLEASE TELL US WHY the BitmapFactory
> methods
> > > > > don't have the option of creating the Bitmap as mutable? A bit
> heavy-
> > > > > handed to force the Bitmap to be immutable, don't you think? For
> that
> > > > > matter, DOES ANYONE AT GOOGLE PAY ANY ATTENTION TO THIS GROUP?  You
> > > > > post to the Apple Developer groups, you get an answer (even on the
> > > > > weekend) from a real live person who knows what he's talking about,
> > > > > and who is (usually) on the Apple payroll. Not here.
> >
> > > > > Second question. I figured I would check the available memory
> before
> > > > > loading the bitmap, then load it at reduced resolution if
> necessary.
> > > > > But Runtime.getRuntime().freeMemory() returns values that make no
> > > > > sense. For example, if I put this in the onCreate of my first
> (main)
> > > > > activity:
> > > > > long freeMemory = Runtime.getRuntime().freeMemory();
> > > > > Log.d("tag",String.valueOf(freeMemory));
> > > > > freeMemory = Runtime.getRuntime().maxMemory();
> > > > > Log.d("tag",String.valueOf(freeMemory));
> > > > > I get a total memory of 16,777,216, but free memory of only
> 472,824.
> > > > > This can't be right.
> >
> > > > > The above is with the emulator. When I try it with my Samsung
> Galaxy
> > > > > Tab, I don't get any information, because Log.d() doesn't seem to
> work
> > > > > at all with the actual hardware. Why is that?
> >
> > > > > Some real assistance with these problems would be much appreciated.
> > > > > Google? Anyone home?
> >
> > > > > Matthew Fleming, MD
> > > > > Fleming Dermatopathology, LLC
> > > > > DermVision, LLC
> >
> > > > > --
> > > > > 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<android-developers%2bunsubscr...@googlegroups.com>
> <android-developers%2Bunsubs­cr...@googlegroups.com
> ><android-developers%2Bunsubs
> > > cr...@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<android-developers%2bunsubscr...@googlegroups.com>
> <android-developers%2Bunsubs­cr...@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- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> 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<android-developers%2bunsubscr...@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

Reply via email to