Does this work?  I took a 9patch png that works fine if I use it via
setBackgroundResource(), but instead loaded the png bytes and decoded
them via BitmapFactory to get a Bitmap and used the getNinePatchChunk
() method in an attempt to create a NinePatch object from the bitmap.
Everything runs ok until the constructor for NinePatch(bitmap, chunk,
src) causes the app to crash... no stacktrace, but a ton of internal
debug diagnostics are sent to logcat... none of which makes any sense
to me nor points to the problem.


On Mar 2, 8:14 pm, Romain Guy <[email protected]> wrote:
> The nine patch chunk can be returned by the Bitmap class. Load a
> Bitmap with BitmapFactory, then call getNinePatchChunk() to get the
> chunks. The padding is a bit more complicated. You need to first
> create a Rect and pass that Rect to the approprite
> BitmapFactor.decode*() method. While decoding the 9patch,
> BitmapFactory will fill that Rect with the padding as encoded in the
> 9patch.
>
>
>
> On Mon, Mar 2, 2009 at 6:11 PM, Dianne Hackborn <[email protected]> wrote:
> > This isn't really intended to be used much by apps.  The byte[] is the raw
> > data of the PNG 9-patch extension chunk that we defined for android, which
> > aapt generates; you'll have to build that all yourself, and look at the
> > ResourceTypes.h header file for a description of its contents.  The padding
> > is just the padding around the image, which is returned by the Drawable.
>
> > On Mon, Mar 2, 2009 at 5:37 PM,Rmac<[email protected]> wrote:
>
> >> I am trying to create a NinePatchDrawable programmatically, but there
> >> is no documentation on the constructor's argruments (Bitmap bitmap,
> >> byte[] chunk, Rect padding, String srcName).  Does anyone know what
> >> chunk and padding are... and how to specify them?
>
> >> Thanks.
>
> > --
> > Dianne Hackborn
> > Android framework engineer
> > [email protected]
>
> > 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.
>
> --
> Romain Guy
> Android framework engineer
> [email protected]
>
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to