Just as I suspected there is a bug in Honeycomb that allows me to work
around not having a setHasAlpha function.

Using the new inMutable option in BitmapFactory.Options I can decode a
dummy JPG and because it is a JPG the opaque hint is set. Now whatever
set function you call on the bitmap, the opaque flag is never cleared
and so it optimizes the drawing. It is rather silly though that I have
to do it this way.

I also wonder how the Android team is going to fix the actual "bug" in
Honeycomb. There are four ways as I see it:

1) When inMutable is set it always clears the opaque hint.  This would
be dumb because it assumes the worst case scenario.
2) For every set function check if it has transparent values so it can
clear the opaque flag.  Lots of work and not very fast
3) Add a XRGB_8888 Config.  Not sure what kind of work is involved
here.
4) Make the setHasAlpha public.  This would be the easiest
solution :-)

On Jan 25, 10:57 pm, webmonkey <webmonke...@gmail.com> wrote:
> Hi Romain
>
> Looking further into the Android source code when you create a 32-bit
> color bitmap the system always assumes you have alpha and there is no
> way to turn it off. Only when you load a JPEG or something does the
> system set the flag to ignore it.
>
> That is an unnecessary performance penalty that can easily be avoided.
> For Honeycomb could you please make the setHasAlpha public or provide
> an XRGB_8888 config. For the upcoming tablets we are going to draw
> even more and bigger bitmaps.
>
> On Jan 24, 10:01 pm,webmonkey<webmonke...@gmail.com> wrote:
>
>
>
> > But that seems to be the only way to tell the system that it can
> > ignore the alpha channel. Bitmap.hasAlpha() just returns the flag.
>
> > I am updating the bitmap a lot with copyPixelsFromBuffer so how do I
> > tell the system that it can ignore the alpha channel?
>
> > On Jan 24, 9:49 pm, Romain Guy <romain...@android.com> wrote:
>
> > > No you cannot. Methods marked @hide are not part of the public API. They 
> > > are
> > > not present in ADT's android.jar so you cannot compile against it. We also
> > > might rename or remove such APIs at any point in the future.
>
> > > On Mon, Jan 24, 2011 at 12:42 PM,webmonkey<webmonke...@gmail.com> wrote:
> > > > Ah thanks, I just checked the Android source and there is the
> > > > following function
>
> > > > public void setHasAlpha(boolean hasAlpha) {
> > > >    nativeSetHasAlpha(mNativeBitmap, hasAlpha);
> > > > }
>
> > > > But it is set to @hide so it is not in the docs, can we use this
> > > > function?
>
> > > > On Jan 24, 6:14 pm, Romain Guy <romain...@android.com> wrote:
> > > > > The system can detect when a ARGB_8888 bitmap is opaque (see
> > > > > Bitmap.hasAlpha()).
>
> > > > > On Mon, Jan 24, 2011 at 8:26 AM,webmonkey<webmonke...@gmail.com>
> > > > wrote:
> > > > > > Now that Gingerbread has moved to 32-bit windows is there a way to
> > > > > > create a 32-bit bitmap without alpha to improve drawing performance 
> > > > > > of
> > > > > > opaque bitmaps?
>
> > > > > > Something like Bitmap.createBitmap( 512, 512,
> > > > > > Bitmap.Config.XRGB_8888  )
>
> > > > > > Or does the system somehow detect that the bitmap is opaque?
>
> > > > > > --
> > > > > > 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%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%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
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to