DO NOT DO THIS.  This marshalling format is private to the system and class,
and can change arbitrarily across releases.

On Mon, Dec 1, 2008 at 2:58 PM, Koush <[EMAIL PROTECTED]> wrote:

>
> I inspected Bitmap.cpp and found this function:
>
> static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
>                                     const SkBitmap* bitmap,
>                                     jboolean isMutable, jobject
> parcel) {
>    if (parcel == NULL) {
>        SkDebugf("------- writeToParcel null parcel\n");
>        return false;
>    }
>
>    android::Parcel* p = android::parcelForJavaObject(env, parcel);
>
>    p->writeInt32(isMutable);
>    p->writeInt32(bitmap->config());
>    p->writeInt32(bitmap->width());
>    p->writeInt32(bitmap->height());
>    p->writeInt32(bitmap->rowBytes());
>
>    if (bitmap->getConfig() == SkBitmap::kIndex8_Config) {
>        SkColorTable* ctable = bitmap->getColorTable();
>        if (ctable != NULL) {
>            int count = ctable->count();
>            p->writeInt32(count);
>            memcpy(p->writeInplace(count * sizeof(SkPMColor)),
>                   ctable->lockColors(), count * sizeof(SkPMColor));
>            ctable->unlockColors(false);
>        } else {
>            p->writeInt32(0);   // indicate no ctable
>        }
>    }
>
>    size_t size = bitmap->getSize();
>    bitmap->lockPixels();
>    memcpy(p->writeInplace(size), bitmap->getPixels(), size);
>    bitmap->unlockPixels();
>    return true;
> }
>
> I can manually marshal a Bitmap parcel in the proper format, and then
> append the custom byte buffer, and then use createFromParcel to create
> a bitmap. That gets me indirect access to creating a bitmap directly
> from a byte buffer. It's a bit of a hack obviously, and not ideal. Is
> there a better way to do this?
>
> On Dec 1, 2:41 pm, Koush <[EMAIL PROTECTED]> wrote:
> > I'm trying to populate a create a bitmap from something other than an
> > RGBA int array.
> > However, the Bitmap creation overloads only take int arrays as inputs.
> >
> > In particular, I have a byte buffer that is in the R5G6B5 format that
> > I want to load directly into a bitmap. The format is supposedly
> > supported internally, but I can't figure out how to create the bitmap
> > without doing the R5G6B5 to A8R8G8B8 conversion first.
> >
>


-- 
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.

--~--~---------~--~----~------------~-------~--~----~
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